Question
Guessing Game Class in java The class will generate a random number of 1 to 15, and then check to see if the user guessed
Guessing Game Class in java
The class will generate a random number of 1 to 15, and then check to see if the user guessed the number correctly. If the number is incorrect, the user should have the chance to guess again, until they guess the right number or they guess 10 times. The program should keep track of the number of guesses the user has had, and print this value at the end.
The class should have one defined Constructor. This constructor should call on a private method within the class to generate the random number; and set the private data field with the number generated. It should also have a method to check the guess to see if it was correct. The guessing method should return a Boolean value to determine if the user keeps guessing. The class should have a method that returns a Boolean value to check the users input to see if it is valid.
After each guess, the program should print out the users guess and how many guesses they have left. If the guess was incorrect at the end of the program, the program should print out that the user had 10 guesses that were incorrect, and should print out the correct random number from the class. If the guess was correct, the program should print out how many guesses it took to get the correct answer.
There should be a seperate class that the program should be able to use. The class should be named Guess and the program to run the class should be named GuessingGame.
Should have proper comments
Only allowed to import java.util Random and java.util Scanner.
Should not have the user's guess or the count as a data field.
Cannot use constants.
Should not have a method for the number of guesses.
Check for user input if its between 1 and 15. If not, that guess doesn't count towards the total number of guesses.
Should print out the random number after the game no matter if the user won or lost.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started