For the most part this semester, we have provided the main()
method to control your program and you implemented specific methods. This time, we've provided you all the methods needed to make a hangman game, and you need to write the main()
method. The javadoc has what methods were already written for you and their basic functionality. This will be very helpful for controller
method in the Practical!
Take a look at the javadoc and the code provided to you. Refresh/familiarize yourself with the rules of hangman.
Create a file called HangmanMain
. Make a new main()
method. This is where you will write all your code.
For this method, you will need to:
- Create a new
HangmanGame
object - Call the
printScreen()
method (remember how to call methods on different objects!) - Use
getInput("Would you like easy or hard words? ")
to get user input on what difficulty they would like - Call
initializeWords()
, passing inselectDifficulty()
, which requires the input from the user you just got. - Call
wordSelect()
. - Print the initial hangman gallows by calling
getZero()
. - Call
printWordProgress()
- While the game is not finished, get input from the user on what letter they guess using
getInput("Guess a letter: ")
and callguess()
, passing in the guess input.
Take a moment to run the game and make sure it works properly.
To turn in your assignment, click through the link on Canvas, upload your files to Zybooks and click submit for grading. Note you can do this more than once.
Note:
HardHangmanWords.txt
was modified slightly from https://www.hangmanwords.com/words.