Interface IHangmanWord


public interface IHangmanWord

A class representing a "word in play", that is, the word which is being guessed, along with status of which characters of it have been guessed (correctly or otherwise), etc.
Implementations should have a constructor that takes one argument, a string, and makes a hangman word out of it.


Field Summary
static char UNGUESSED_POSITION_MARKER
          A character used to indicate unguessed positions of a word.
 
Method Summary
 java.lang.String getCurrentWordGuess()
          Tells the word as a string, the same length and characters as the full correct correct answer, except that unguessed positions are marked as such with a special character (such as '_').
 java.lang.String getWord()
          Tells the word as a simple string; this is the "dictionary" form of the full word as the players think of it.
 boolean recordCharacterGuess(char c)
          Takes note of the fact that another character has been guessed.
 int remainingUnguessedChars()
          Tells how many character positions of the word are still unguessed.
 

Field Detail

UNGUESSED_POSITION_MARKER

public static final char UNGUESSED_POSITION_MARKER
A character used to indicate unguessed positions of a word.

See Also:
Constant Field Values
Method Detail

getWord

public java.lang.String getWord()
Tells the word as a simple string; this is the "dictionary" form of the full word as the players think of it.

Returns:
a string representing the dictionary form of the word.

getCurrentWordGuess

public java.lang.String getCurrentWordGuess()
Tells the word as a string, the same length and characters as the full correct correct answer, except that unguessed positions are marked as such with a special character (such as '_').

Returns:
a string representing the current guess of the word.

recordCharacterGuess

public boolean recordCharacterGuess(char c)
Takes note of the fact that another character has been guessed. If the guess is correct, then a following call to remainingUnguessedChars or getCurrentWordGuess will return a different value than before this latest guess, following the rules of play of the game.
Postconditions: if the guess is correct, the value of the partially guessed word is updated.

Parameters:
c - any character value (the character being guessed).
Returns:
a value indicating the result of the guess (true for correct, false for incorrect).

remainingUnguessedChars

public int remainingUnguessedChars()
Tells how many character positions of the word are still unguessed. For example, if the word is "flood", and the current match of correctly guessed characters is "_l__d", the value returned is 3.
Note that this number is NOT necessarily the same as the number of guesses remaining in the game!

Returns:
number of unmatched position in the word.