Class GuessRange

java.lang.Object
  extended by GuessRange

public class GuessRange
extends java.lang.Object

This class maintains a range of integers and a random integer in that range, and allows the user to guess at the number.


Constructor Summary
GuessRange(int low, int high)
          Constructs a range with the given limits and selects a random number from within that range.
 
Method Summary
 int getHighLimit()
          Accessor method to determine the current upper limit on the range.
 int getLowLimit()
          Accessor method to determine the current lower limit on the range.
 int getNumberOfGuesses()
          Accessor method to determine the number of guesses made so far.
 java.lang.String makeGuess(int guess)
          Handles a guess at the number in the range, returning the result and updating the range appropriately.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GuessRange

public GuessRange(int low,
                  int high)
Constructs a range with the given limits and selects a random number from within that range.

Parameters:
low - lower limit on the range (inclusive)
high - upper limit on the range (inclusive)
Method Detail

getLowLimit

public int getLowLimit()
Accessor method to determine the current lower limit on the range.

Returns:
the lower limit (inclusive)

getHighLimit

public int getHighLimit()
Accessor method to determine the current upper limit on the range.

Returns:
the upper limit (inclusive)

getNumberOfGuesses

public int getNumberOfGuesses()
Accessor method to determine the number of guesses made so far.

Returns:
the number of guesses (i.e., times makeGuess has been called)

makeGuess

public java.lang.String makeGuess(int guess)
Handles a guess at the number in the range, returning the result and updating the range appropriately.

Returns:
result of the guess (either "CORRECT", "TOO HIGH", or "TOO LOW")