Class HangmanGame
Object
HangmanGame
-
Field Summary
Modifier and TypeFieldDescription(package private) boolean
(package private) HangmanView
(package private) String
(package private) char[]
(package private) int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
correctGuess
(String guess) Controls functionality when user guesses a correct letter.void
Controls the guessing functionality of the game.void
incorrectGuess
(String guess) Controls functionality when user enters an incorrect guess.void
initializeWords
(String file) Initializes the wordList.void
Prints the current user's current progress in guessing the word.selectDifficulty
(String difficulty) Selects the appropriate word list file to use for the user's selected difficulty.void
Selects a random word from the wordList and sets the game's hangman word.
-
Field Details
-
view
HangmanView view -
wordList
-
word
String word -
wordArray
char[] wordArray -
wrongGuesses
int wrongGuesses -
incorrectLetters
-
finished
boolean finished
-
-
Constructor Details
-
HangmanGame
public HangmanGame()
-
-
Method Details
-
selectDifficulty
Selects the appropriate word list file to use for the user's selected difficulty. Note that if "hard" is not entered (ignoring case), the default is using the easy word list.- Parameters:
difficulty
- User-selected difficulty- Returns:
- String name of .txt file to set wordList with
-
initializeWords
Initializes the wordList. Requires a String that names a file to read words in from. Reads the words in from that file and adds the words to the wordList ArrayList.- Parameters:
file
- File to read words in from
-
wordSelect
public void wordSelect()Selects a random word from the wordList and sets the game's hangman word. -
guess
Controls the guessing functionality of the game.- Parameters:
guess
- User's letter guess
-
correctGuess
Controls functionality when user guesses a correct letter.- Parameters:
guess
- User's letter guess
-
incorrectGuess
Controls functionality when user enters an incorrect guess.- Parameters:
guess
- User's letter guess
-
printWordProgress
public void printWordProgress()Prints the current user's current progress in guessing the word.
-