Dear Sir,
I have made a question by myself. For example: I am playing the card game to my friend. The card has Spade, Heart, Club and Spade as usual but no number. How can I do if I only play five time and finally there is a record of the comparison XX : XX.
The following is my answer:
program Spade;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
Count, Num, Computer : integer;
Choice, compChar : char;
begin
Num:=0;
Computer:=0;
randomize;
for Count:=1 to 5 do
repeat
writeln('Welcome to play the game of Spades');
readln(Choice);
until (Choice = 'S') or (Choice = 'H') or (Choice = 'C') or (Choice = 'D');
case Choice of
'S': writeln('You have got Spade');
'H': writeln('You have got Heart');
'C': writeln('You have got Club');
'D': writeln('You have got Diamond');
end;
Computer:= random(4);
case Computer of
0:
begin
writeln('Computer have chosen Spade');
compChar:= 'S';
end;
1:
begin
writeln('Computer have chosen Heart');
compChar:= 'H';
end;
2:
begin
writeln('Computer have chosen Club');
compChar:= 'C';
end;
3:
begin
writeln('Computer have chosen Diamond');
compChar:= 'D';
end;
end;
if ((Choice='S') and (compChar='H') and (compChar='C') and (compChar='D')) or ((Choice='H') and (compChar='C') and (compChar='D')) or ((Choice='C') and (compChar='D')) then
begin
writeln('You win');
end
else
if ((Choice='S') and (compChar='S')) or ((Choice='H') and (compChar='H')) or ((Choice='C') and (compChar='C')) or ((Choice='D') and (compChar='D')) then
begin
writeln('You draw');
end
else
writeln('You loss');
readln;
end.
But how can I do if I want to make changes to choose randomly?