java.lang.ObjectHangmanGame
public class HangmanGame
A program to play a game of Hangman.
Constructor Summary | |
---|---|
HangmanGame()
Creates a new HangmanGame object with a default wordList. |
|
HangmanGame(java.lang.String onlyWord)
Creates a new HangmanGame object, with the wordlist containing only the given word. |
Method Summary | |
---|---|
java.lang.String |
arrayToString(char[] array)
A helper method that returns a String representation of the given char[]. |
boolean |
containsLetter(char guessedLetter)
A helper method that checks if the word-to-guess contains the gussed letter |
char |
getGuess()
A helper method that prompts the user to provide a guessed letter. |
int |
leftToGuess()
A helper method which counts how many letters are left to guess |
boolean |
playAgain()
A helper method that asks the user whether they want to play again. |
void |
playGame()
A method that plays a complete game of Hangman. |
void |
replaceLetter(char guessedLetter)
A helper method that replaces blank spots in the word-so-far with the guessedLetter |
void |
setupGame()
A helper method which re-initializes variables for the start of a new game. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HangmanGame()
public HangmanGame(java.lang.String onlyWord)
onlyWord
- The single word in the wordlist, used for testing and debuggingMethod Detail |
---|
public java.lang.String arrayToString(char[] array)
array
- the char[] to convert to a String.
public boolean containsLetter(char guessedLetter)
guessedLetter
- the letter that was guessed
public char getGuess()
public int leftToGuess()
public boolean playAgain()
public void playGame()
public void replaceLetter(char guessedLetter)
guessedLetter
- the letter that was guessedpublic void setupGame()