HangmanAA.java For this program, you will create the game Hangman. (If you are unsure of how to play Hangman, Google it.) The game will start by asking player 1 for a word or phrase (can be multiple words). Then player 1 will be asked how many missed guesses are allowed by player 2. Once this information is received, player 2 will take over. (Have the program print many blank lines of space so that player 2 can’t see what player 1 entered.) The instructions should be displayed for player 2 as well as the number of misses they’re allowed to make before they lose the game. The screen should also output dashes or underscores to represent each letter of player 1’s secret word/phrase. Player 2 should guess one letter at a time. Case should not matter. Typing x or X should give the same result. If that letter is present in the mystery phrase, then it should be displayed. (It will replace the dash/underscore in that spot. Spaces, punctuation, and all other non-alphabetic characters should always be displayed to player 2.) If the letter is not present, the player should be notified that they used up a missed guess. This should go on until either the player loses because they have no more missed guesses or they have correctly guessed all letters. At that point the game should end and either a “Sorry, you lose.” or “Well done. You win the game!” should be displayed. Below is a sample of how this game should look. No try-catch blocks are necessary. Output Example: (>>> represents user’s input) Welcome to Hangman. Player 1, enter the mystery word or phrase. >>>Cats rule. How many missed guesses is Player 2 allowed? >>>3 Welcome Player 1. Below is your mystery phrase. You are allowed 3 missed guesses before you lose. Enter a letter. ___ ___ ___ ___ ___ ___ ___ ___. >>>a ___ a ___ ___ ___ ___ ___ ___. Well done. You have 3 missed guesses left. >>>e ___ a ___ ___ ___ ___ ___ e. Well done. You have 3 missed guesses left. >>>s ___ a ___ s ___ ___ ___ e. Well done. You have 3 missed guesses left. >>>p ___ a ___ s ___ ___ ___ e. That letter is not present. You have 2 missed guesses left. >>>d ___ a ___ s ___ ___ ___ e. That letter is not present. You have 1 missed guesses left. >>>t ___ a t s ___ ___ ___ e. Well done. You have 1 missed guesses left. >>>c c a t s ___ ___ ___ e. Well done. You have 1 missed guesses left. >>>r c a t s r ___ ___ e. Well done. You have 1 missed guesses left. >>>t c a t s r ___ ___ e. Well done. You have 1 missed guesses left. >>>u c a t s r u ___ e. Well done. You have 1 missed guesses left. >>>l c a t s r u l e. Well done. You win the game! in java
HangmanAA.java
For this
The game will start by asking player 1 for a word or phrase (can be multiple words). Then player 1 will be asked how many missed guesses are allowed by player 2. Once this information is received, player 2 will take over. (Have the program print many blank lines of space so that player 2 can’t see what player 1 entered.)
The instructions should be displayed for player 2 as well as the number of misses they’re allowed to make before they lose the game. The screen should also output dashes or underscores to represent each letter of player 1’s secret word/phrase.
Player 2 should guess one letter at a time. Case should not matter. Typing x or X should give the same result. If that letter is present in the mystery phrase, then it should be displayed. (It will replace the dash/underscore in that spot. Spaces, punctuation, and all other non-alphabetic characters should always be displayed to player 2.) If the letter is not present, the player should be notified that they used up a missed guess. This should go on until either the player loses because they have no more missed guesses or they have correctly guessed all letters. At that point the game should end and either a “Sorry, you lose.” or “Well done. You win the game!” should be displayed. Below is a sample of how this game should look. No try-catch blocks are necessary.
Output Example: (>>> represents user’s input)
Welcome to Hangman. Player 1, enter the mystery word or phrase.
>>>Cats rule.
How many missed guesses is Player 2 allowed?
>>>3
Welcome Player 1. Below is your mystery phrase. You are allowed 3 missed guesses before you lose. Enter a letter.
___ ___ ___ ___ ___ ___ ___ ___.
>>>a
___ a ___ ___ ___ ___ ___ ___.
Well done. You have 3 missed guesses left.
>>>e
___ a ___ ___ ___ ___ ___ e.
Well done. You have 3 missed guesses left.
>>>s
___ a ___ s ___ ___ ___ e.
Well done. You have 3 missed guesses left.
>>>p
___ a ___ s ___ ___ ___ e.
That letter is not present. You have 2 missed guesses left.
>>>d
___ a ___ s ___ ___ ___ e.
That letter is not present. You have 1 missed guesses left.
>>>t
___ a t s ___ ___ ___ e.
Well done. You have 1 missed guesses left.
>>>c
c a t s ___ ___ ___ e.
Well done. You have 1 missed guesses left.
>>>r
c a t s r ___ ___ e.
Well done. You have 1 missed guesses left.
>>>t
c a t s r ___ ___ e.
Well done. You have 1 missed guesses left.
>>>u
c a t s r u ___ e.
Well done. You have 1 missed guesses left.
>>>l
c a t s r u l e.
Well done. You win the game!
in java
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images