Question: In JAVA 1. Application this class should instantiate a Hangman object that play. 2. Hangman this class encapsulates all of the game play with the

In JAVA

1. Application this class should instantiate a Hangman object that play.

2. Hangman this class encapsulates all of the game play with the following methods/responsibilities:

a. Constructor - instantiates the Dictionary object from which you can choose words for your game.

b. loadWL loads the win/loss record from a file. You can seed the file with 0,0 for the wins and losses for the first run. After that, the file will contain the values from previous runs.

c. writeWL writes the win/loss record to a file. Remember, you are keeping a running total, so you will add the number of wins and losses from your current run to the numbers that were in the file Hint: you might want to save those two values when you first read them so you can use them later.

d. playGame implements the main game loop for your game.

3. Dictionary - loads the word list from a file and supports choosing a random word.

a. Constructor calls the readFile method.

b. readFile reads the specified file and fills up the wordlist array. The file should contain 200 words from 4 to 12 letters long. Hint: The Scanner class will work fine for reading this file. The book has a great example to show you to do it if you are unsure.

c. chooseWord randomly chooses a word from the array and returns it.

General Functionality

The program should begin by asking the user if they want to play. If yes, the game should choose a word and then ask for guesses. Each time a player guesses wrong, it should decrement the total number of guesses (5 incorrect guesses allowed, on the 6th incorrect guess the game ends with a loss). Regardless of a win or loss, the player should have the option of playing again.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!