Free Pascal Tutorial 7 Part 1 of 2 - Guess My Number - Lazarus

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
11,626
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Oct 11, 2009

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

  • likes, 1 dislikes

Link to this comment:

Share to:

Uploader Comments (SchoolFreeware)

  • var answer,guess,cnt:integer; game: string; begin repeat writeln('Please select a game'); writeln('A) 10'); writeln('B)100'); writeln('C) 1000'); write('Selection : '); readln(game); until (game - 'A') or (game = 'B') or (game = 'C'); readln; end. And I'm getting error: (25,7) Operation not supported for types ,,antistring',, , ,,chart,, Can you help me?
  • @ChanZXZ (game - 'A') should be (game = 'A')

see all

All Comments (8)

Sign In or Sign Up now to post a comment!
  • when i try to type uses crt, sysutils it says File Not Found (Sysutils.tpu)

  • @SchoolFreeware Thank you, now it works

  • @SchoolFreeware Thank you, now it works.

  • im trying to make a password based program need help !

  • @somebuke Did u got it? If no i can tell you.

  • hey tnx for the video xD and some more plis can you help me when i save my work and do build he saves me a few files but a wont only the file that opens the program in pascal how to select to save me only file for pascal ????

  • Loading comment...
Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more