|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--Coin
A Coin has an orientation, either heads
or tails, and a value.
| Constructor Summary | |
Coin()
A default Coin is created with a random orientation
and a value of one. |
|
Coin(int value)
Creates a Coin with the given
value and a random orientation. |
|
| Method Summary | |
boolean |
equals(Coin c)
Two Coins are equals
to one another if they have the same value and
the same orientation. |
Coin |
flip()
This Coin is flipped in the air
and returned. |
int |
getValue()
Returns the value of this Coin. |
boolean |
isHeads()
This predicate returns true if
the coin is oriented heads up, and false
otherwise. |
boolean |
isTails()
This predicate returns true if
the coin is oriented tails up, and false
otherwise. |
String |
toString()
Returns a String representation of
the coin's state. |
Coin |
turnOver()
Inverts the orientation of this Coin. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Coin()
Coin is created with a random orientation
and a value of one.
public Coin(int value)
Coin with the given
value and a random orientation.
| Method Detail |
public Coin flip()
Coin is flipped in the air
and returned.
public int getValue()
Coin.
public Coin turnOver()
Coin. If
it was heads before, it's tails afterward. If is
was tails before, it's heads afterward.
public boolean isHeads()
true if
the coin is oriented heads up, and false
otherwise.
public boolean isTails()
true if
the coin is oriented tails up, and false
otherwise.
public boolean equals(Coin c)
Coins are equals
to one another if they have the same value and
the same orientation.
public String toString()
String representation of
the coin's state.
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||