< Previous | Contents | Next >

Introducing Hangman

In the Hangman program, the computer picks a secret word and the player tries to guess it one letter at a time. The player is allowed eight incorrect guesses. If he or she fails to guess the word in time, the player is hanged and the game is over. Figure 4.6 shows the game.


image

Figure 4.6

The Hangman game in action


 

Planning the GameSetting Up the ProgramInitializing Variables and ConstantsEntering the Main LoopGetting the Player’s GuessEnding the Game