Question: IN JAVA PLEASE! Create a java class called WordGuess In the class implement the following methods public static String makeUserWord(String theWord) Takes the word the
IN JAVA PLEASE!
Create a java class called WordGuess
In the class implement the following methods
public static String makeUserWord(String theWord)
Takes the word the player is trying to guess and generates a pattern of '*' values to represent letters that have not yet been guessed. For example, if the word were "dog" this method would return "***".
public static boolean isInWord(char guess, String theWord)
Returns true if the guessed character is in the word, false otherwise. For example, if the guess were 'x' and the word were "xylophone" this method would return true.
public static String updateUserWord(char guess, String userWord, String theWord)
Returns a userWord with all occurrences of '*' corresponding to the current guess replaced with that guess. For example, if the word was "fetch" and the user word was "****h" and the user guessed 'e', the return string would be "*e**h".
public static String updateGuesses(String guesses, char guess)
Updates the list of guesses with the current guess. The update should only add the guess if it does not already exist in the list. The new guess must be placed at the end of the existing list of guesses. For example, if guesses were "tabg" and the current guess were 'f', this method would return "tabgf".
public static String displayUserWord(String userWord)
Returns a String that is the userWord with spaces between each letter and each '*' replaced with an '_'. For example, if the userWord is "fe***" this method would return "f e _ _ _". Note that there is no space before the 'f' and after the last '_'.
public static String displayGuesses(int strikes, String guesses)
Returns a String in the form "Strikes: %d\tGuesses: %s", with the list of guesses separated by spaces. For example, if there were 3 strikes and guesses were "bcd", this method would return"Strikes: 3\tGuesses: b c d".
The following terms will be used consistently throughout the method descriptions below.
theWord
The current word to guess. It will be preserved throughout play.
userWord
A pattern that represents the progress the user is making on the word.
guess
The letter that the user is guessing.
strikes
The number of bad guesses the user has made.
guesses
A list of characters that the user has guessed.
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
