Hangman: Pattern Prelude

These questions refer to Hangman.java, a straightforward procedural decomposition of the game Hangman.

  1. If the program should allow the user to play again (repeatedly) after a game is over, where will this code go?

  2. The user isn't shown what letters have already been used, although repeated guesses aren't penalized. How would you modify the program to show the user what letters haven't been guessed yet?

  3. How would you modify the program to allow difficulty levels, e.g., easy is 10 misses, medium is 8 misses, and hard is 6 misses before hanging.

  4. The words are currently hard-wired in the class Hangman. Outline a method for reading words from a file, where the filename is either hardwired or a parameter to the program. What issues arise when words are read from a file?

  5. How would you modify the program to allow the user to guess the whole word at once?

  6. How would you modify the program to draw ASCII-art stick figures of a hanging person, e.g., simply:
       O     O     O     \O     \O/ 
             |     |      |      | 
            /     / \    / \    / \
    

  7. Suppose that instead of guessing words a quiz-like hangman is introduced, e.g., more like Wheel-of-Fortune (but no buying vowels). For example, "What is the capital of Pennsylvania?" or "What is the capital of Utah?". How would you modify the program to incoporate this idea?

  8. Why isn't this program object-oriented? What changes/redesign/refactoring are needed to make it more object-oriented? What issues will arise in modifying the program to use a GUI (application or applet)?


Owen L. Astrachan
Last modified: Fri Oct 27 01:02:01 EDT 2000