Question: - Avoid updating the display more ( or less ) often than you need to - All words / letters displayed to the user should
Avoid updating the display more or less often than you need to
All wordsletters displayed to the user should be uppercase
All unguessed hidden letters should be displayed with underscores
Players may provide either lower or upper case input, and both should work interchangeably guessing a is the same as guessing A
Feel free to create additional methods to organize your code, but don't change any of the provided public method or constructor signatures
Players start with guesses remaining a larger value will make the program crash dramatically
HangmanProgram
In the main method, set up some useful variables: create one of type HangmanDisplay, and another of type HangmanDictionary. Using those variables and the chooselnitialWord method, also create a variable of type HangmanGameState.
Choose an initial word. Hint What class that we've seen previously could you use to help accomplish that?
Add logic to run the game: have the HangmanGameState make a guess repeatedly until the game is over, and then display the result of the game to the player. Hint Don't overthink it The HangmanGameState will have most of the interesting logic.
HangmanGameState
First, we'll set up the data: Add fields to handle the word guessing one to store the hidden word, one to store the word shown to the user, and one to store what letters have already been guessed. These fields should have a private access modifier. You'll need to pick an appropriate type for them!
Add a field to handle the number of guesses remaining for this game, everyone will start with guesses remaining.
Add a field to store a HangmanDisplay object remember that the syntax for fields will still be the same for object types: the type HangmanDisplay and then the field name.
Fill in the constructor to HangmanGameState. Make sure to initialize all five fields, even though only two parameters are provided! To start with, the user should see one underscore per letter in the hidden word as they guess letters, those s will be replaced with the actual letter.
Fill in the isGameOver method: the game is over when either the player has no guesses remaining, or they've guessed all the letters, and no s are left. Hint what method on String could be helpful here?
Fill in the displayResult method: this method should display what the word was regardless of if the player won or not and the final state of the hangman display. If the player won, there should be a final game message including the word 'won'; otherwise, the message should include the word 'lost' for example, 'You won. 'The game is won!!! or 'Won' are all options for the winning message Hint You'll need to call methods on the HangmanDisplay field to accomplish this
Fill in the makeOneGuess method: a To make a guess, first display the current hangman and the inprogress word to guess. b Next, get the guess from the player. You'll need to make sure that the player hasn't already guessed this letter if they have, ignore the guess. c If they haven't guessed the letter before, and it's a letter of the word to guess, update their inprogress word to reveal the correctly guessed lettersd If the guessed letter is not in the word its an incorrect guess reduce the number of guesses the player has left. Note Only an incorrect guess uses up one of the guesses remaining.
Find and fix any bugs: the autograder will test some unusual inputs as well as looking for common structural problems in the code, so you'll want all those tests to pass!
can you please help me write a code
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
