Question
In Java create a word guessing game called Hangman . The game is played between the computer and one player . The player needs to
In Java create a word guessing game called Hangman. The game is played between the computer and one player. The player needs to guess the correct word by guessing a single character each time. The player is allowed upto 8 lives in one game. Every incorrect guess costs the player one life. The player loses the game if all 8 lives were used up, and wins if the complete word is guessed any time before that. (please include comments in your code)
Level 1
Choose a specific word of your liking and hardwire it in your code so you already know the size of the word.
Notify the player
Number of characters in the word
8 lives left
In each turn
Prompt the player to enter a char
If the entered char is exists in the word, the player is notified about the number of times the char appears in the word.
If the entered char is not present in the word, the player is notified of its absence from the word.
Stop the game when all 8 lives are used up.
Game should end immediately, if the player has guessed the correct word
Output should display the correct word
Output should also display whether the game was a win or a loss.
Sample output is shown below
Sample output word to guess is "program" Your Word has 7 characters You have 8 lives. Let's play! Enter a char sorry! d is not a character in this word. Try again! You have 7 lives left Enter a char sorry! e is not a character in this word. Try again! You have 6 lives left. Enter a char Yes, the character o appears once in your word. You have 6 lives left Enter a char Yes, the character p appears once in your word. You have 6 lives left Enter a char Yes, the character appears twice in your word. You have 6 lives left Enter a char Yes, the character g' appears once in your word. You have 6 lives left Enter a char Yes, the character a appears once in your word. You have 6 lives left Enter a char Yes, the character m' appears once in your word. You have 6 lives left That is it! You win! The correct word is "program If the player used up all 8 lives, your output must say- Sorry, you have no lives left. You lose! The correct word is javg 2/22/2017Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started