CSCI 201 Fall 2000: Hangman

Code Written in Class

Program: Hangman

The following classes have been partially completed, you are to use them in completing a program for playing hangman as described below.

In addition, the program hang.cpp shows how the classes can be used. It's not a complete version of a game, but it's something to use to get started.

Requirements

Specifying the Word Source

Your program should take words from the file mywords.txt. In reading words from that file, the class WordSource should return any word in the file with equal probability. You can do this using a RandGen object. The files that you need to create this object are randgen.h and randgen.cpp. You can read the words directly from a file or read the words into a StringSet object, either approach is acceptable. If you chose to use a StringSet object, you will have to add a StringSet variable to the private section of the class definition. The files needed to create StringSet objects were provided in assignment 4.

Playing the Game

You can write new classes, or just add to the existing classes, but the final game must have the following properties:
  1. A letter that has already been guessed can be guessed again with no penalty. This means guessing 'a' twice counts for only one miss if 'a' is not in the word.

  2. Before each guessed letter, the user should be shown a list of letters that have already been guessed, along with the word being guessed. The word being guessed may be partially revealed if some letters have been guessed.

  3. Before each guessed letter, the user should be told how many misses are left until being hung (when the game is over).

  4. After a game, either a win or a loss, the user should be asked if she wants to play again.

Some Helpful Hints