Class RandomNumberGenerator
java.lang.Object
RandomNumberGenerator
- All Implemented Interfaces:
NumberGenerator
public class RandomNumberGenerator extends Object implements NumberGenerator
Produces random numbers using Java's Random class
-
Field Summary
-
Constructor Summary
Constructors Constructor Description RandomNumberGenerator()
Generates numbers completely randomly.RandomNumberGenerator(long seed)
Generates numbers randomly based off of a specified seed. -
Method Summary
Modifier and Type Method Description int
next(int bound)
Grabs another integer from the Random number generator that is between 0 and bound (inclusive).
-
Field Details
-
r
Random r
-
-
Constructor Details
-
RandomNumberGenerator
public RandomNumberGenerator()Generates numbers completely randomly. -
RandomNumberGenerator
public RandomNumberGenerator(long seed)Generates numbers randomly based off of a specified seed.- Parameters:
seed
- - a seed to pass to the Random number generator.
-
-
Method Details
-
next
public int next(int bound)Grabs another integer from the Random number generator that is between 0 and bound (inclusive).- Specified by:
next
in interfaceNumberGenerator
- Parameters:
bound
- - the max value that can be returned by this call to next- Returns:
- a random number between 0 and bound (inclusive).
-