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 pre-set 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 8th 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 5 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 Array class.) 1. You must use For loops in this lab. 2. You may not use the Array class or any of its methods in this lab. 3. If appropriate for this algorithm, you should validate any input from the user to make sure the data input is an appropriate value to work in your program’s logic. You don’t have to worry about validating that it is the correct data type. For now, assume the user is only giving you the correct data type and just worry about validating the value given is usable in your program
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 pre-set 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 8th 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 5 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 Array class.)
1. You must use For loops in this lab.
2. You may not use the Array class or any of its methods in this lab.
3. If appropriate for this
sure the data input is an appropriate value to work in your program’s logic. You don’t
have to worry about validating that it is the correct data type. For now, assume the user
is only giving you the correct data type and just worry about validating the value given is
usable in your program
Step by step
Solved in 5 steps with 5 images