Class NumberPicker

java.lang.Object
  |
  +--NumberPicker

public class NumberPicker
extends java.lang.Object

This class is the number picker It picks a random number between the min, and max fields (inclusive) and will let you know if you guess the right number.

Author:
Barbara Ericson ericson@cc.gatech.edu

Field Summary
static int DEFAULT_MAX
          The default maximum value
static int DEFAULT_MIN
          The default minimum value
static long DEFAULT_SEED
          The default seed is based on the current time
 
Constructor Summary
NumberPicker()
          Constructor that takes no arguments.
NumberPicker(int min, int max, long seed)
          Constructor that takes the min, max, and seed
NumberPicker(long seed)
          Constructor that takes a seed for the random number generator
 
Method Summary
 int getMax()
          Method to get the maximum value that can be picked
 int getMin()
          Method to get the minimum value that can be picked
 boolean isCorrect(int guess)
          Check if the given guess is equal to the picked number
 void pickANumber()
          Method to pick a random number between the min and max field values (inclusive)
 void setMax(int value)
          Method to set the maximum value
 void setMin(int value)
          Method to set the minimum value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MIN

public static final int DEFAULT_MIN
The default minimum value

See Also:
Constant Field Values

DEFAULT_MAX

public static final int DEFAULT_MAX
The default maximum value

See Also:
Constant Field Values

DEFAULT_SEED

public static final long DEFAULT_SEED
The default seed is based on the current time

Constructor Detail

NumberPicker

public NumberPicker()
Constructor that takes no arguments. It will set the min, max, and seed to the default values


NumberPicker

public NumberPicker(long seed)
Constructor that takes a seed for the random number generator

Parameters:
seed - the seed for the random number generator

NumberPicker

public NumberPicker(int min,
                    int max,
                    long seed)
Constructor that takes the min, max, and seed

Parameters:
min - the min to use
max - the max to use
seed - the seed for the random number generator
Method Detail

getMin

public int getMin()
Method to get the minimum value that can be picked

Returns:
the minimum value that can be picked

getMax

public int getMax()
Method to get the maximum value that can be picked

Returns:
the maximum value that can be picked

setMin

public void setMin(int value)
Method to set the minimum value

Parameters:
value - the new minimum to use

setMax

public void setMax(int value)
Method to set the maximum value

Parameters:
value - the new maximum to use

pickANumber

public void pickANumber()
Method to pick a random number between the min and max field values (inclusive)


isCorrect

public boolean isCorrect(int guess)
Check if the given guess is equal to the picked number

Parameters:
guess - the guessed number
Returns:
true if the guess is correct else false