Class GuessingGame

java.lang.Object
  |
  +--GuessingGame

public class GuessingGame
extends java.lang.Object


Constructor Summary
GuessingGame()
          Creates a new instance of the guessing game.
GuessingGame(int max)
          Creates a new instance of the guessing game.
GuessingGame(int min, int max)
          Creates a new instance of the guessing game.
 
Method Summary
 boolean guessCorrect(int guess)
          Checks to see if the player's choice matches the secret number
 boolean guessTooHigh(int guess)
          Checks to see if the player's choice is higher than the secret number
 boolean guessTooLow(int guess)
          Checks to see if the player's choice is lower than the secret number
 boolean inRange(int guess)
          Checks to see if the player's guess greater than or equal to the minimum possible value and less than or equal to the maximum possible value
 java.lang.String toString()
          Returns a String representation of this GuessingGame which gives the secret number
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GuessingGame

public GuessingGame()
Creates a new instance of the guessing game. The minimum possible value is 1, while the maximum possible number is 100.

GuessingGame

public GuessingGame(int max)
Creates a new instance of the guessing game. The minimum possible value is 1, while the maximum possible number is the parameter.
Parameters:
max - The maximum number to be guessed

GuessingGame

public GuessingGame(int min,
                    int max)
Creates a new instance of the guessing game. The range of the secret number is determined by the constructor's parameters: the minimum and maximum possible values are passed, in that order. If min > max, the values are swapped automatically.
Parameters:
min - The minimum possible number to be guessed
max - The maximum possible number to be guessed
Method Detail

guessCorrect

public boolean guessCorrect(int guess)
Checks to see if the player's choice matches the secret number
Parameters:
guess - The number guessed by the player
Returns:
true if the guess is equal to the secret number, false otherwise

guessTooHigh

public boolean guessTooHigh(int guess)
Checks to see if the player's choice is higher than the secret number
Parameters:
guess - The number guessed by the player
Returns:
true if the guess is greater than the secret number, false otherwise

guessTooLow

public boolean guessTooLow(int guess)
Checks to see if the player's choice is lower than the secret number
Parameters:
guess - The number guessed by the player
Returns:
true if the guess is less than the secret number, false otherwise

inRange

public boolean inRange(int guess)
Checks to see if the player's guess greater than or equal to the minimum possible value and less than or equal to the maximum possible value
Parameters:
guess - The number guessed by the player
Returns:
true if the guess is within range, false otherwise

toString

public java.lang.String toString()
Returns a String representation of this GuessingGame which gives the secret number
Returns:
a String representation of this GuessingGame
Overrides:
toString in class java.lang.Object