Simple, Quality, Awesome Software

Hangman

Required Knowledge Before Starting

  • Lists (Chapter 25).
  • File I/O (Chapter 29).
  • User Input (Chapter 8).

Problem Description

Create a program that will play hangman with the user, allowing the user to guess words.

The program should be able to load words out of a file. (Any format will work, but a nice simple format is one that has each word on a single line.)

The program should pick one of the words randomly.

The program should show the user the current state of the guessed word, using underscores or some other placeholder to show characters that have not been correctly guessed, and fill in the correct letter for already guessed letters.

The program should keep track of a growing list of incorrectly guessed letters and display those to the user as well.

When the user has incorrectly guessed a certain, configurable number (in code) of letters, the player will lose. If the player correctly fills in all of the letters in the word, they win.

Solution

Hangman.zip