Package org.cis1200
Class RandomNumberGenerator
java.lang.Object
org.cis1200.RandomNumberGenerator
- All Implemented Interfaces:
NumberGenerator
Produces random numbers using Java's Random class. This class is implemented for you.
-
Constructor Summary
ConstructorsConstructorDescriptionGenerates pseudo-random numbers.RandomNumberGenerator
(long seed) Generates numbers randomly based off of a specified seed. -
Method Summary
Modifier and TypeMethodDescriptionint
next
(int bound) Grabs another integer from the Random number generator that is between 0 (inclusive) and bound (exclusive).
-
Constructor Details
-
RandomNumberGenerator
public RandomNumberGenerator()Generates pseudo-random numbers. -
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 (inclusive) and bound (exclusive).- 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 (inclusive) and bound (exclusive).
-