using java ( easy way please) Write a reverse Hangman game in which the user thi
ID: 3638185 • Letter: U
Question
using java( easy way please)
Write a reverse Hangman game in which the user thinks of a word and the computer tries to
guess the letters in that word. The user tells the computer how many letters the word contains.
Limit your program to a maximum of 6 guesses. Use a random number generator to generate the
guesses. Use the following code to generate your letter guesses randomly:
// picks a letter at random that we haven't yet guessed
public static char getGuess(String guesses) {
Random r = new Random();
char guess;
do {
guess = (char)('A' + r.nextInt(26));
} while (guesses.indexOf(guess) != -1);
return guess;
}
Your program should be stored in a file called ReverseHangman.java.
Log of execution (user input underlined)
This program plays a game of reverse hangman.
You think up a word and I'll try to guess
the letters.
How many letters are in your word? 2
+--+
| |
|
|
|
|
+-----
I've got 0 of the 2 letters so far
I guess Q
Is that letter in the word? n
+--+
| |
| O
|
|
|
+-----
I've got 0 of the 2 letters so far
I guess O
Is that letter in the word? n+--+
| |
| O
| |
|
|
+-----
I've got 0 of the 2 letters so far
I guess B
Is that letter in the word? n
+--+
| |
| O
| |
|
|
+-----
I've got 0 of the 2 letters so far
I guess T
Is that letter in the word? n
+--+
| |
| O
| |
| /
|
+-----
I've got 0 of the 2 letters so far
I guess X
Is that letter in the word? n
+--+
| |
| O
| |
| /
|
+-----
I've got 0 of the 2 letters so far
I guess H
Is that letter in the word? n
+--+
| |
| O
| /|
| /
|
+-----
I've got 0 of the 2 letters so far
I guess G
Is that letter in the word? n
+--+
| || O
| /|
| /
|
+-----
You beat me this time.