Class UnfilteredRandom

java.lang.Object
  extended by UnfilteredRandom
All Implemented Interfaces:
RandomWithParity

public class UnfilteredRandom
extends java.lang.Object
implements RandomWithParity

A random number generator that returns a number within the specified bound and of alternating parity. The number returned from the first call is even, then odd, then even and so on.

Correspondence (abstraction relation):
numCalls = |history|
Author:
paolo

Field Summary
private  java.util.Random generator
          Generates a stream of random numbers.
private  int numCalls
          Number of times the generateNumber method has been called.
 
Constructor Summary
UnfilteredRandom()
          Initially, no calls have been made.
 
Method Summary
 int generateNumber(int upperBound)
          Generates a random number in the specified interval.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numCalls

private int numCalls
Number of times the generateNumber method has been called.


generator

private java.util.Random generator
Generates a stream of random numbers.

Constructor Detail

UnfilteredRandom

UnfilteredRandom()
Initially, no calls have been made.

Method Detail

generateNumber

public int generateNumber(int upperBound)
Generates a random number in the specified interval.

Specified by:
generateNumber in interface RandomWithParity
Parameters:
upperBound - the maximum value that can be generated by this call
Returns:
0 <= generateNumber <= upperBound
See Also:
RandomWithParity.generateNumber(int)