At this point in the tutorial series, we can start putting programs together from the previous tutorials.
We will use the classic game Guess My Number. It is a very boring game to play, by todays standards, but programing the game can be interesting.
These are the requirements of the game:
The game will prompt the user to select one of three games. The games are 1-10, 1-100, 1-1000. If the user does not enter the right selection, the program will display the selection again. Once the user selects the game, the program will randomize the number and prompt the user for a guess. The guess will be checked with the computers number. If the guess was not correct, the computer will prompt the user to guess higher or lower. If the guess was correct, the computer will display the number of times the user guessed, and the game will be over. The computer will prompt the user to play again. If the user does want to play again, the program will return to the game menu. If the user does not want to play again, the computer will quit the program.
Before we get to the code, there is are built-in functions called clrscr() and UpperCase(). Clrscr() clears the screen and needs the crt unit added to the unit section to work. UpperCase() converts the text to uppercase and needs the sysutils unit loaded into the unit section to work. UpperCase() is used to prevent the program from being case sensitive. The computer sees A differently than a. By converting the case, the user can enter both lower and uppercase answers and the computer will respond to the input the same way.
This program can be downloaded for free at http://www.schoolfreeware.com
Diagram Designer can be downloaded for free at: http://logicnet.dk/DiagramDesigner
ChanZXZ 4 months ago
@ChanZXZ (game - 'A') should be (game = 'A')
SchoolFreeware 4 months ago