Class RandNumGenerator

java.lang.Object
  extended by RandNumGenerator

public class RandNumGenerator
extends java.lang.Object

Kalamazoo College Utility Classes:
The RandNumGenerator class provides a representation for random number generators.

Example of how to use RandNumGenerator:


       RandNumGenerator randNumGen = new RandNumGenerator();
       int randomInt = randNumGen.nextInt(4);
       double randomDouble = randNumGen.nextDouble();
    

Version:
10 January 2008
Author:
Alyce Brady

Constructor Summary
RandNumGenerator()
          Constructs a random number generator.
 
Method Summary
 boolean nextBoolean()
          Returns a pseudorandom, uniformly distributed boolean value from this random number generator's sequence.
 double nextDouble()
          Returns a pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.
 int nextInt(int n)
          Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandNumGenerator

public RandNumGenerator()
Constructs a random number generator.

Method Detail

nextBoolean

public boolean nextBoolean()
Returns a pseudorandom, uniformly distributed boolean value from this random number generator's sequence. The values true and false are produced with (approximately) equal probability. For more technical details, see the documentation for the Math.random() method.

Returns:
a pseudorandom, uniformly distributed boolean value from this random number generator's sequence

nextDouble

public double nextDouble()
Returns a pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.

Returns:
a pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.

nextInt

public int nextInt(int n)
Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence. For more technical details, see the class documentation for the Random class.

Parameters:
n - the bound on the random number to be returned. Must be positive.
Returns:
a pseudorandom, uniformly distributed int value between 0 (inclusive) and n (exclusive).