
/**
 * This class serves as a simple ESP tester.  Using this class, the user
 * can repeatedly guess a number and see if it matches the random number 
 * selected by the computer.
 *   @author  Dave Reed
 *   @version 9/13/04
 */

public class ESPTester
{
    private int maxNumber;  // computer pick will be between 1 and maxNumber

    /**
     * Constructs an ESPTester that can generate random ints from the range 1..max.
     *   @param max the maximum value in the range (it is assumed that max >= 1)
     */
    public ESPTester(int max)
    {
        maxNumber = max;
    }

    /**
     * Takes the user's guess and compares it with a randomly selected number.
     * 
     * @param  guess the user's guess (assumed to be in the range 1..maxNumber)
     * @return a String specifying whether the guess was correct
     */
    public String guessNumber(int guess)
    {
        int pick = (int)(Math.random()*maxNumber) + 1;
        
        if (guess == pick) {
            return ("You were correct, my number was " + pick);
        }
        else {
            return ("Sorry, my number was " + pick);
        }
    }

}
