Hangman, First-pass at Text MVC

  1. The UML class diagram provides a somewhat informative global view of the newly structured program. The solid, gray lines indicate object containment, e.g., a Hangman object contains a GameController object.

    Based on the names/parameters/return types of the methods shown in the diagram and without looking at the code, where is the Word object created that's used in the game (see the diagram for GameController)?

  2. Where is the Gallows object created (and it's degree of difficulty specified?


    You may want/need to look at code to answer the following questions. You may also want to look at The script from a sample run of the program.

  3. The Interface WordFactory is implemented by DefaultWordFactory and the only WordFactory in the program is used in Hangman. How would you change the program to use the default factory or a factory that reads from a file of words?

  4. The letters that have been guessed are "blanked" out and the letters that have not been guessed are displayed prior to the each prompt from the user. Where is the code that prints these letters? How would you modify the code to print only the already guessed letters, not those that have not been guessed? Which is better from a user-interface perspective?

  5. Explain the logic behind the code below that adds a part to the Gallows object. boolean alphUsed = myAlphabet.doGuess(s.charAt(0)); if (! w.doGuess(s.charAt(0)) && alphUsed) { myGallows.addPart(); }


Owen L. Astrachan
Last modified: Wed Nov 1 17:20:37 EST 2000