Hangman -- My Model

Chapter: Hangman -- My Model

In an earlier lab you looked at a hangman program. The game is this:

The model for this game needs the following state:

In my model, I provide the following public methods:

public void guess(Character c); 
/* Process the letter c */

public int getLives();          
/* Return the number of lives the player has remaining */

public String getDisplayWord(); 
/*  Returns the string with all unguessed letters replaced by '_' */

public boolean playing();
/* Return true if the game has not ended */

public boolean win();
/* Return true if the player has won */

The constructor for my model passes in the initial number of lives the player is granted and the target word or phrase.


rhyspj@gwu.edu