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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education