ai1.serverjava.numguess.model
Class NumberGuessBean

java.lang.Object
  extended byai1.serverjava.numguess.model.NumberGuessBean
All Implemented Interfaces:
java.io.Serializable

public class NumberGuessBean
extends java.lang.Object
implements java.io.Serializable

Model for the number guessing game. Encapsulates a random number between 1 (inclusive) and 100 (inclusive) and tells wether the correct number is guessed or not.

See Also:
Serialized Form

Constructor Summary
NumberGuessBean()
          Generates a random number and constructs an instance with that number.
 
Method Summary
 java.lang.String getHint()
          Returns a String indicating if the random number is higher or lower than the last guess.
 int getRandomNumber()
          Returns the random number.
 boolean guess(int guess)
          Checks a guess.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NumberGuessBean

public NumberGuessBean()
Generates a random number and constructs an instance with that number.

Method Detail

guess

public boolean guess(int guess)
Checks a guess.

Parameters:
guess - The value that is checked against the random number.
Returns:
true if the guess was correct, false if the guess was incorrect.

getRandomNumber

public int getRandomNumber()
Returns the random number.

Returns:
The random number.

getHint

public java.lang.String getHint()
Returns a String indicating if the random number is higher or lower than the last guess.

Returns:
The String higher if the random number is higher than the last guess, lower if the random number is lower and null if it is equal to the last guess..