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

    Fields
    Modifier and Type Field Description
    (package private) Random r  
  • 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).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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 interface NumberGenerator
      Parameters:
      bound - - the max value that can be returned by this call to next
      Returns:
      a random number between 0 and bound (inclusive).