|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectTossableFairCoin
public class TossableFairCoin
An instance of this class models a coin that can be tossed to yield heads or tails, with equal probability.
| Constructor Summary | |
|---|---|
TossableFairCoin()
Initializes the coin's fields. |
|
| Method Summary | |
|---|---|
boolean |
isHeads()
Reports whether or not the coin is showing heads. |
boolean |
isTails()
Reports whether or not the coin is showing tails. |
int |
numHeadsTossed()
Reports the number of times during its lifetime that the coin has been tossed to yield heads. |
int |
numTailsTossed()
Reports the number of times during its lifetime that the coin has been tossed to yield tails. |
int |
numTimesTossed()
Reports the number of times during its lifetime that the coin has been tossed. |
void |
toss()
Tosses the coin, after which there is a probability of 1/2 that the coin shows heads, and similarly for tails. |
java.lang.String |
toString()
Returns a string indicating which side of the coin is showing, heads or tails. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TossableFairCoin()
| Method Detail |
|---|
public boolean isHeads()
public boolean isTails()
public int numHeadsTossed()
public int numTailsTossed()
public int numTimesTossed()
public java.lang.String toString()
toString in class java.lang.Objectpublic void toss()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||