/** * An oracle for numeric guessing games. You tell the oracle the number, * and the oracle can answer questions about guesses. * * @author Samuel A. Rebelsky * @version 1.0 of January 1999 */ public class NumberGameOracle { // +--------+------------------------------------------------------------ // | Fields | // +--------+ /** The number we're trying to guess. */ long solution; // +--------------+------------------------------------------------------ // | Constructors | // +--------------+ /** * Create a new oracle who knows that the solution is the given value. */ public NumberGameOracle(long solution) { this.solution = solution; } // NumberGameOracle // +---------+----------------------------------------------------------- // | Methods | // +---------+ /** * Check if a guess is correct. */ public boolean isCorrect(long guess) { return guess == solution; } // isCorrect(long) /** * Check if a guess is too small. */ public boolean isSmall(long guess) { return guess < solution; } // isSmall(long) /** * Check if a guess is too large. */ public boolean isLarge(long guess) { return guess > solution; } // isLarge(long) } // class NumberGameOracle