The player tries to guess a number from 1 to 100 randomly selected by the computer. (use random)
Important: If the user gives a non-number or number less than 1 or greater than 100, the program should again ask the player to enter a number without this error counting to the failed his efforts.
The program waits for a user to enter a number (The game must begin in two ways:1) finding the number from the player and 2) the player's voluntary termination)and checks if it is the same as the one the computer chooses.
If the player does not find the number, the program displays the message "The hidden number is larger" or the message "The hidden number is smaller", depending on selected number by the computer. The check is repeated until the player finds the number or ends the game.
The player wins 10 minus failed attempts points and 0 points if the failed attempts are 10 or more.
When the player finds the requested number, the program displays "You found it after X attempts, and you earned Y points" (where X is the number of attempts and Y is the points earned as above. Immediately after the program displays the message "you want to play again (YES / NO)". If the player answers YES then the game starts again by calculating a NEW random number.
Aucun commentaire:
Enregistrer un commentaire