Class HangmanGame

Object
HangmanGame

public class HangmanGame extends Object
  • Field Details

  • Constructor Details

    • HangmanGame

      public HangmanGame()
  • Method Details

    • selectDifficulty

      public String selectDifficulty(String difficulty)
      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

      public void initializeWords(String file)
      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

      public void guess(String guess)
      Controls the guessing functionality of the game.
      Parameters:
      guess - User's letter guess
    • correctGuess

      public void correctGuess(String guess)
      Controls functionality when user guesses a correct letter.
      Parameters:
      guess - User's letter guess
    • incorrectGuess

      public void incorrectGuess(String guess)
      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.