Package org.cis1200

Class RandomNumberGenerator

java.lang.Object
org.cis1200.RandomNumberGenerator
All Implemented Interfaces:
NumberGenerator

public class RandomNumberGenerator extends Object implements NumberGenerator
Produces random numbers using Java's Random class. This class is implemented for you.
  • 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 interface NumberGenerator
      Parameters:
      bound - - the max value that can be returned by this call to next
      Returns:
      a random number between 0 (inclusive) and bound (exclusive).