Dear Sir / Madam,
The following is the game of Rock, Paper, Scissors. But I don't know why computer is always choose Rock.
My Answer:-
program RPS5;
{$APPTYPE CONSOLE}
uses
SysUtils,
ourcrt;
var
Computer : integer;
Choice, Move : char;
begin
repeat
writeln('Rock(R), Paper(P), Scissors(S)');
readln(Choice);
until (Choice = 'R') or (Choice = 'P') or (Choice = 'S');
case Choice of
'R': writeln('You have chosen Rock');
'P': writeln('You have chosen Paper');
'S': writeln('You have chosen Scissors');
end;
Computer:= random (2);
case Computer of
0: begin writeln('Computer have chosen Rock');
Move:='R';
if Move=choice then begin Writeln('Draw') end
else
if Choice='S' then begin Writeln ('You lose') end
else writeln('You win') end;
1: begin writeln('Computer have chosen Paper');
Move:='P';
if Choice=Move then begin Writeln('Draw') end
else
if Choice='R' then begin Writeln ('You lose') end
else writeln('You win') end;
2: begin writeln('Computer have chosen Scissors');
Move:='S';
if Choice=Move then begin Writeln('Draw') end
else
if Choice='P' then begin Writeln ('You lose') end
else writeln('You win') end;
end;
sleep (10000);
end.
Could you tell me what is wrong of my answer,
Cheers,