Question: Task Write a Java program that will allow the user to play a hangman game repeatedly until they choose to stop. The game should randomly
Task
Write a Java program that will allow the user to play a hangman game repeatedly until they choose to stop. The game should randomly choose a secret word from a preset list of words for the user to guess. Store the list of words available for play in an array so you can randomly choose them by index during game play.
During a turn, the user will guess one letter at a time. Each letter in the secret word should display as an asterisk until the letter is guessed by the user. When a correct letter is guessed, the letter should be displayed in the correct position in place of the asterisk. The user hangs himself with the th wrong guess and loses the game.
Make a character array to hold the characters and asterisks representing the word being guessed. You can change the contents of this array as the letters are guessed and revealed. In other words, this array can be used to display the current state of the secret word each round.
Here is the list of words the game should choose from for the secret word technology, square, variable, program, documentation, and additional words of your choice. At the end of the game, the user should have the ability to play again if they would like.
Make sure you create appropriate methods to make your code efficient.
Restrictions you are only allowed to use primitive data types, Strings data types and arrays for this assignment. Specifically you are not allowed to use the StringBuilder class or objects of the explicit Array type, which we have not gone over in class.
Some sample output from a working game is shown below:
First Wrong Guess:
Sorry, the letter you guessed is not in the secret word.
Secret Word:
Guess another letter:
Second Wrong Guess:
Sorry, the letter you guessed is not in the secret word.
O
Secret Word:
Guess another letter:
Correct Guess:
Good job!
The letter e is in the secret word.
Secret Word:
ee
Last Wrong Guess:
O
Secret Word:
tee
Sorry, you lost!
You guessed wrong letters.
Additional Assignment Requirements
You may NOT use Java libraries or programming concepts not yet learned in this course. This assignment is designed to
assess that you understand the concepts being presented in the course this week, not concepts we will learn at a later time.
You may NOT discuss this problem with your classmates. This assignment is independent work. Work copied from another
student or an online resource will result in enforcement of EKU's Academic Integrity policy as discussed in the syllabus.
You must use appropriate spacing, indention, naming conventions, and documentation in your Java program.
You will upload your completed work by attaching your HWFirstnameLastname.java to your submission in
Blackboard for the lab assignment. If you need help locating your java file to submit, refer to the FAQ discussion board for help or
reach out to your lab assistantinstructor for help. DO NOT submit the entire project folder to be graded!
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
