Guessing Game With Tries

Geoffrey Challen // 2022.7.0

Let's complete a class to implement a guessing game. When the class is created we'll set a secret number and 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 constructor accepting the secret value and the maximum number of tries, in that order, both as int values. If the maximum number of tries is negative or zero, throw an IllegalArgumentException.

Provide a public method guess accepting a guess (as an int) and returning a boolean. If the guess matches the secret, return true; otherwise return false. If the number of tries is exceeded, or if the secret has already been successfully guess, throw an IllegalArgumentException. Provide a getter for the number of tries used, but do not expose any other object state publicly.