|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectAlternatingCoin
public class AlternatingCoin
Generates a binary coin (0 or 1) in strict alternating sequence. With every flip of the coin, the coin changes from 0 to 1 or vice versa. The first call returns a 0, then 1, then 0, and so on.
| Field Summary | |
|---|---|
private boolean |
doneEvenFlips
True if and only if an even number of invocations to this AlternatingCoin have been made. |
| Constructor Summary | |
|---|---|
AlternatingCoin()
Initialially, zero flips have been performed, hence doneEvenFlips is true. |
|
| Method Summary | |
|---|---|
int |
generateNumber(int upperBound)
Returns a 0 or a 1 (alternating) and ignoring upperBound parameter. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private boolean doneEvenFlips
| Constructor Detail |
|---|
public AlternatingCoin()
| Method Detail |
|---|
public int generateNumber(int upperBound)
generateNumber in interface RandomWithParityupperBound - the maximum value that can be generated by this call
RandomWithParity.generateNumber(int)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||