I have the following code and just wondered if anyone could tell me why it doesnt compile and what edits I need to do to make it work.
It's basically a card game which follows these rules:
1) Imagine computer randomly selects a card from a pack of cards.
2) The first player must guess the suit then its value
3) After each guess for the suit a message will display whether the
player was correct or not.
4) After each guess for the value a message will display whether the
player was correct, too high or too low.
Here is the code:
procedure game;
var suitguess,valueguess : string;
valueguessint, suitguessint,valid : integer;
validbool : boolean;
begin
generateno;
guesses := 0;
repeat
suitcorrect := false;
valuecorrect := false;
repeat
Writeln('Enter Suit Guess');
writeln;
writeln('1 : Club');
writeln('2 : Spade');
writeln('3 : Heart');
writeln('4 : Diamond');
writeln;
writeln;
Readln(suitguess);
val(suitguess, suitguessint, valid);
validbool := true;
if (suitguessint <1) or (suitguessint >4) or (valid <> 0) then
begin
validbool := false;
writeln('Please enter a number from 1 to 4');
writeln('Press any key to try again');
readkey;
end;
until validbool = true;
If suitguessint = suitno then
begin
writeln('Correct');
suitcorrect := true;
end
else
writeln('Incorrect');
readkey;
begin
repeat
Writeln('Enter Value Guess');
writeln('1 = ace');
writeln('11 = jack');
writeln('12 = queen');
writeln('13 = king');
writeln('all other numbers are represented by thier number value');
writeln;
readln(valueguess);
val(valueguess, valueguessint, valid);
validbool := true;
if (valueguessint <1) or (valueguessint >13) or (valid <> 0) then
begin
validbool := false;
writeln('Please enter a number from 1 to 13');
writeln('Press any key to try again');
readkey;
end;
until validbool = true;
If valueguessint = value then
begin
writeln('Correct');
valuecorrect := true
end
else
begin
writeln('Incorrect');
If value < valueguessint then
writeln(' The value is less than ',valueguess)
else
writeln(' The value is greater than ',valueguess);
end;
readkey;
end;
guesses := guesses +1;
until (suitcorrect AND valuecorrect) = true;
writeln('Game complete');
writeln('press any key to continue to next game');
totalguesses[activeplayer(gameno)] := totalguesses[activeplayer(gameno)] + guesses;
readkey;
end; {proc}
The code was part of a bigger code and has been edited a bit. Now I believe I just need to put a start, end and add the variables etc to make it run as a single game. If anyone fancies taking a stab at it I would be most grateful.
Ideally im trying to get the code into an executable form so the game plays as described.
Thanks.
This post has been edited by Sarah.K: 13 March 2005 - 07:06 PM

New Topic/Question
Reply



MultiQuote



|