Guessing Game With Tries
Let's complete a class to implement a guessing game. When the class is created we'll save a secret number and set a maximum number of tries. Then we'll provide a method allowing someone to guess the secret number, but limit the number of guesses appropriately.
Create a public class
GuessingGame with a primary constructor accepting the secret value and the maximum number of
tries, in that order, both as
If the maximum number of tries is negative or zero, throw an
Provide a public method
guess accepting a guess (as an
Int) and returning a
If the guess matches the secret, return
true; otherwise return
If the number of tries is exceeded, or if the secret has already been successfully guess, throw an
Provide a getter for the number of tries used, but do not expose any other object state publicly.