|
program guess;
uses Types, QuickDraw, Events, MiscTool;
var
ans, rand, loop, score: Integer;
begin
{ Setup }
graphics(640);
setRandSeed(getTick);
hidecursor;
writeln('*** Guessing Game *** By: Ding Wen');
writeln;
{ Set varibles }
loop := 0;
score := 110;
rand := random mod 100 + 1;
while loop <= 10 do begin
loop := loop + 1;
score := score - 10;
{ Ask question }
writeln('Guess a number from 1 to 100.');
readln(ans);
{ Check answer }
if ans < rand then
writeln('Too low.')
else begin
if ans > rand then
writeln('Too High.')
else begin
if ans = rand then begin
writeln('You Win!');
writeln('You had ', loop, ' tries.');
writeln('Good luck next time!');
leave;
end;
end;
end;
end;
{ Write score }
writeln('Here is your score:',score, '/100');
writeln('Click to quit.');
repeat until button (0);
end. |
|