Add ability to retry

This commit is contained in:
IllusionMan1212
2018-06-19 19:28:18 +02:00
parent d865c2c1c1
commit 9e7d263bf3
+25 -11
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,15 +98,18 @@ 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
clrscr;
writeln('Select Difficulty'); writeln('Select Difficulty');
writeln('[1] Press 1 for Easy mode (10 tries)'); writeln('[1] Press 1 for Easy mode (10 tries)');
writeln('[2] Press 2 for Medium mode (5 tries)'); writeln('[2] Press 2 for Medium mode (5 tries)');
@@ -107,4 +120,5 @@ begin
2 : Medium; 2 : Medium;
3 : Hard; 3 : Hard;
end; end;
until (dialog = 'n') or (dialog = 'N');
end. end.