Answered You can hire a professional tutor to get the answer.
In this project, you are going to implement the word guessing game, Hangman 2.
In this project, you are going to implement the word guessing game, Hangman 2.0. Your program is going to get a random word from an enumerated list (instructions below) and then let the user guess letters until they get the word correct, run out of guesses, or solve the word. A unique characteristic of Hangman 2.0 is that the user must specify a subset of the available spaces to check. So, for each guess, the user provides the letter to guess along with the spaces he/she wants to check. The number of guesses allowed will be set to 20. It is recommended that you use a constant value for this in case you want to change it while debugging. It's easier to debug if you set this variable to a small value as you will run out of guesses quicker. The number of spaces allowed for the guesses will be a user input. The number of spaces allowed can range from 1 to the length of the secret word, inclusive. You can assume that the user will input an integer for the number of spaces allowed. After a round ends, the program will print the score for that round and the total score. Both the round score and the total score can be stored as integers - just truncate any decimal place after the whole number value. The total score is a running total of the scores from each round played. The score for each round is calculated as follows:
roundScore= (guessesRemaining*10)/numSpacesAllowed
guessesRemaining is the number of guesses that the user didn't use in that round • numSpacesAllowed is the number of spaces allowed in each guess. Using a lower value for this variable will increase the score for that round.
An incorrect guess causes the program to decrement the number of remaining guesses, but a correct guess does not affect the number of remaining guesses. To simplify the program, we will only use lowercase letters in the random words generated. Also, invalid input does not affect the number of remaining guesses. Your job is to write Java program in a file called Hangman2.java that allows the user to play up to 20 games of Hangman2 (the maximum number of games the user can play - that's how many items are in the word bank). When the program begins, it will ask for the number of spaces allowed for each round. If they enter an invalid number, the program should ask them to try again until they input a valid number (see examples below). The program then asks the user for their guess. The program will read the letter to guess and the spaces before checking if they are valid. If the user enters invalid input for a guess, the program will ask them to try again until they input a valid guess. After the game ends, the program will print the score for the round and the user's overall score and ask if they would like to play again. Many of these scenarios are shown in the examples below. Your program should behave the same way for all test cases given. You should also come up with additional test cases in order to thoroughly test your application.
Requirements: • You cannot use arrays or the StringBuilder class to implement this project. You can only work with the String methods discussed in lecture. • You must use index 0 as the index of the first character in your word. For example, if the secret word is "hardware", the letter 'h' is at index 0. So, if the user specifies space 0, you should uncover the 'h'. Failure to use correct indexing will have a negative impact on your assignment grade. • In order to facilitate the testing of your program, you must include a boolean variable called testingMode initialized to true in the top of your class (under the class declaration and above your main method) as shown below. private static final boolean testingMode = true; If the value of the variable testingMode is true, your program will display the secret word the user should guess. This helps you test your program and helps us grade your program. Without this variable, we will not know what the correct answer is. See example executions below to see the output. On the other hand, if the value of the variable testingMode is set to false, the program will not show the value of the secret word. When you submit your code, make sure the variable is set to true. • Use the RandomWord.newWord() method to generate random words, and this method should only be called once per game, and it can be called at most 20 times in a single program run (note: after 20 calls, it issues an error message and terminates). This method is provided to you. However, you must download the RandomWord.java file from the labs and projects website, and place RandomWord.java in the same source directory as Hangman2.java. RandomWord.java randomly picks a word from an enumerated list and returns it when the the newWord() method is called. If you are interested in how it works, you can look at the source code. Do not modify the source code in RandomWord.java. • The code for this assignment will require loops, decision statements, variables, etc.