| |
|
| java.lang.Object model.Game
Game | public class Game implements Serializable(Code) | | Implementation of the actual hangman game model. The model holds the word
generator, the current word, retries remaining and the correctLetters that
have been guessed. It also answers questions such as whether all retries have
been used.
author: Chris Turner author: Jonathan Locke author: Geert Bevin |
Method Summary | |
public int | getGuessesRemaining() Return the number of guesses remaining. | public List<Letter> | getLetters() | public Word | getWord() Get the current word that is being guessed or has been guessed. | public boolean | guess(Letter letter) Guess the given letter for the current word. | public boolean | isLost() Check whether the user has used up all of their guesses. | public boolean | isWon() Check whether the user has successfully guessed all of the correctLetters
in the word. | public void | newGame() | public void | newGame(int guessesAllowed, WordGenerator wordGenerator) Initialise the hangman read for a new game. |
getGuessesRemaining | public int getGuessesRemaining()(Code) | | Return the number of guesses remaining.
The number of guesses |
getWord | public Word getWord()(Code) | | Get the current word that is being guessed or has been guessed.
The current word |
guess | public boolean guess(Letter letter)(Code) | | Guess the given letter for the current word. If the letter matches then
the word is updated otherwise the guesses remaining counter is reduced.
The letter guessed is also recorded.
Parameters: letter - The letter being guessed True if guess was correct |
isLost | public boolean isLost()(Code) | | Check whether the user has used up all of their guesses.
Whether all of the user's guesses have been used |
isWon | public boolean isWon()(Code) | | Check whether the user has successfully guessed all of the correctLetters
in the word.
Whether all of the correctLetters have been guessed or not |
newGame | public void newGame()(Code) | | Play another game with same settings
|
newGame | public void newGame(int guessesAllowed, WordGenerator wordGenerator)(Code) | | Initialise the hangman read for a new game.
Parameters: guessesAllowed - Number of guesses allowed Parameters: wordGenerator - The word generator |
|
|
|