function eightball(n)
% Sherman Wiggin
% AHC Engr 179 - MATLAB
% Spring 2005
% This is a modified function of "why.m
% Uses the official and unofficial magic 8-ball answers 
% according to http://ofb.net/8ball/answers.html

if nargin > 0
    rand('state',n); 
end
a = a_case;
a(1) = upper(a(1));
disp(a);

%------------------
%function within a function
function a = a_case
switch fix(35*rand)
    case 0,   a = 'Signs point to yes';
    case 1,   a = 'Yes';
    case 2,   a = 'Reply hazy, try again';
    case 3,   a = 'Without a doubt.';
    case 4,   a = 'My sources say no. ';
    case 5,   a = 'As I see it, yes. ';
    case 6,   a = 'You may rely on it. ';
    case 7,   a = 'Concentrate and ask again.';
    case 8,   a = 'Outlook not so good. ';
    case 9,   a = 'It is decidedly so. ';
    case 10,  a = 'Better not tell you now. ';
    case 11,   a = 'Very doubtful.';
    case 12,   a = 'Yes - definitely.';
    case 13,   a = 'It is certain.';
    case 14,   a = 'Cannot predict now. ';
    case 15,   a = 'Most likely. ';
    case 16,   a = 'Ask again later.';
    case 17,   a = 'My reply is no. ';
    case 18,   a = 'Outlook good. ';
    case 19,   a = 'Don''t count on it.';
    case 20,   a = 'Yes, in due time.'; 
    case 21,   a = 'My sources say no.'; 
    case 22,   a = 'Definitely not.'; 
    case 23,   a = 'Yes.'; 
    case 24,   a = 'You will have to wait.'; 
    case 25,   a = 'I have my doubts.'; 
    case 26,   a = 'Outlook so so.'; 
    case 27,   a = 'Looks good to me!'; 
    case 28,   a = 'Who knows?'; 
    case 29,   a = 'Looking good!'; 
    case 30,   a = 'Probably.'; 
    case 31,   a = 'Are you kidding?';
    case 32,   a = 'Go for it!'; 
    case 33,   a = 'Dont bet on it.' ;
    case 34,   a = 'Forget about it.';
    otherwise, a = 'Very doubtful. ';
end

