Class Die

java.lang.Object
  |
  +--Die

public class Die
extends java.lang.Object

The Die class represents a die for games of chance using dice. Bugs: none known


Constructor Summary
Die()
          Constructs a 6 sided die with 1 facing up.
Die(int specifiedSides)
          Constructs a die of a specified number of sides with 1 facing up.
Die(int specifiedSides, int specifiedTop)
          Constructs a die of a given number of sides and side facing up.
 
Method Summary
 int getTop()
          Gets die's side facing up.
 void roll()
          Randomly sets the die's side facing up to be: 1 <= top <= sides.
 void setTop(int specifiedTop)
          Sets die's side facing up to specified value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Die

public Die()
Constructs a 6 sided die with 1 facing up.

Die

public Die(int specifiedSides)
Constructs a die of a specified number of sides with 1 facing up.
Parameters:
givenSides - die's number of sides, assumed to be > 0

Die

public Die(int specifiedSides,
           int specifiedTop)
Constructs a die of a given number of sides and side facing up.
Parameters:
specifiedSides - die's number of sides, assumed to be > 0
specifiedTop - die's side facing up, assumed to be > 0 restricts top <= sides
Method Detail

setTop

public void setTop(int specifiedTop)
Sets die's side facing up to specified value.
Parameters:
specifiedTop - die's side facing up, assumed to be > 0 restricts top <= sides

getTop

public int getTop()
Gets die's side facing up.
Returns:
top side (i.e. side facing up)

roll

public void roll()
Randomly sets the die's side facing up to be: 1 <= top <= sides.