Add ability to retry

This commit is contained in:
IllusionMan1212
2018-06-19 19:28:18 +02:00
parent d865c2c1c1
commit 9e7d263bf3
+35 -21
View File
@@ -1,5 +1,8 @@
program Guessing; program Guessing;
uses crt;
var myRnd, entry, i, choice : integer; var myRnd, entry, i, choice : integer;
dialog : string;
procedure Easy; procedure Easy;
begin begin
@@ -13,8 +16,9 @@ begin
if (entry = myRnd) then if (entry = myRnd) then
begin begin
writeln('BINGO!!!!'); writeln('BINGO!!!!');
readln; writeln();
halt; writeln('Do you want to retry? [Y/N]');
readln(dialog);
end end
else else
if (entry < myRnd) and (i <> 10) then if (entry < myRnd) and (i <> 10) then
@@ -28,7 +32,9 @@ begin
end; end;
end; end;
writeln('GAME OVER!'); writeln('GAME OVER!');
readln(); writeln();
writeln('Do you want to retry? [Y/N]');
readln(dialog);
end; end;
procedure Medium; procedure Medium;
@@ -43,8 +49,9 @@ begin
if (entry = myRnd) then if (entry = myRnd) then
begin begin
writeln('BINGO!!!!'); writeln('BINGO!!!!');
readln; writeln();
halt; writeln('Do you want to retry? [Y/N]');
readln(dialog);
end end
else else
if (entry < myRnd) and (i <> 5) then if (entry < myRnd) and (i <> 5) then
@@ -58,7 +65,9 @@ begin
end; end;
end; end;
writeln('GAME OVER!'); writeln('GAME OVER!');
readln(); writeln();
writeln('Do you want to retry? [Y/N]');
readln(dialog);
end; end;
procedure Hard; procedure Hard;
@@ -73,8 +82,9 @@ begin
if (entry = myRnd) then if (entry = myRnd) then
begin begin
writeln('BINGO!!!!'); writeln('BINGO!!!!');
readln; writeln();
halt; writeln('Do you want to retry? [Y/N]');
readln(dialog);
end end
else else
if (entry < myRnd) and (i <> 3) then if (entry < myRnd) and (i <> 3) then
@@ -88,23 +98,27 @@ begin
end; end;
end; end;
write('GAME OVER!'); write('GAME OVER!');
readln(); writeln();
writeln('Do you want to retry? [Y/N]');
readln(dialog);
end; end;
begin begin
writeln('Hi and welcome to my first guessing game :)'); writeln('Hi and welcome to my first guessing game :)');
writeln('the program will pick a random number between 1 and 100 and you have to guess it'); writeln('the program will pick a random number between 1 and 100 and you have to guess it');
writeln('Good luck!'); writeln('Good luck!');
writeln(); readln();
writeln(); repeat
writeln('Select Difficulty'); clrscr;
writeln('[1] Press 1 for Easy mode (10 tries)'); writeln('Select Difficulty');
writeln('[2] Press 2 for Medium mode (5 tries)'); writeln('[1] Press 1 for Easy mode (10 tries)');
writeln('[3] Press 3 for Hard mode (3 tries)'); writeln('[2] Press 2 for Medium mode (5 tries)');
readln(choice); writeln('[3] Press 3 for Hard mode (3 tries)');
case (choice) of readln(choice);
1 : Easy; case (choice) of
2 : Medium; 1 : Easy;
3 : Hard; 2 : Medium;
end; 3 : Hard;
end;
until (dialog = 'n') or (dialog = 'N');
end. end.