edu.colorado.simulations
Class BooleanSource

java.lang.Object
  extended by edu.colorado.simulations.BooleanSource

public class BooleanSource
extends java.lang.Object

A BooleanSource provides a random sequence of boolean values.

Java Source Code for this class:
http://www.cs.colorado.edu/~main/edu/colorado/simulations/BooleanSource.java


Constructor Summary
BooleanSource(double p)
          Initialize a BooleanSource.
 
Method Summary
 boolean query()
          Get the next value from this BooleanSource.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BooleanSource

public BooleanSource(double p)
Initialize a BooleanSource.

Parameters:
p - a probability
Precondition:
0 <= p and p <= 1.
Postcondition:
This BooleanSource has been initialized so that p is the approximate probability of returning true in any subsequent activation of the query method.
Throws:
java.lang.IllegalArgumentException - Indicates that p is outside of its legal range.
Method Detail

query

public boolean query()
Get the next value from this BooleanSource.

Parameters:
- - none
Returns:
The return value is either true or false, with the probability of a true value being determined by the argument that was given to the constructor.