Interface IGameController


public interface IGameController

Controller for a single game of Hangman.
Implementations should have a constructor which takes a single arguments, a ISessionController object. This will be a reference to the session controller which created this game; needed because the controller has the method to display status and results; the game must call that display method, so it needs a reference to the session controller.


Method Summary
 char askUserForGuess()
          Asks the user to enter the next guessed character.
 java.lang.String getGuessedLetters()
          Tells which letters have been guessed (whether right or wrong), compressed together into a string.
 int getNumGuessesRemaining()
          Tells how many guess are remaining in the current game.
 int playGame(IHangmanWord w)
          Fully plays one game.
 

Method Detail

playGame

public int playGame(IHangmanWord w)
Fully plays one game.

Parameters:
w - the word to be used for this game.
Returns:
the result or score. Details are implementation-dependent, but in general a value of 0 or less should indicate that the player has lost the game; a value greater than 0 indicates that the player has won.

askUserForGuess

public char askUserForGuess()
Asks the user to enter the next guessed character.

Returns:
the letter guessed by the user.

getGuessedLetters

public java.lang.String getGuessedLetters()
Tells which letters have been guessed (whether right or wrong), compressed together into a string.

Returns:
a string containing all and only the letters that have been guessed, in alphabetical order. This string may be empty but will not be null. The string will not contain duplicate letters.

getNumGuessesRemaining

public int getNumGuessesRemaining()
Tells how many guess are remaining in the current game.

Returns:
the number of guesses remaining, or -1 if there is no game in progress.