Class Dice

java.lang.Object
  extended by Dice

public class Dice
extends java.lang.Object

This class is an implementation of a dice object, used for generating random rolls.


Field Summary
static int DEFAULT_NUM_SIDES
          a constant for the number of sides by default
 
Constructor Summary
Dice()
          Default constructor, creates a 6-sided die The die will initially be roll to give it a side up.
Dice(int sides)
          Constructor, creates a die with a number of sides specified by the input parameter The die will initially be roll to give it a side up.
 
Method Summary
 int getNumSides()
          View the number of sides on the die
 int getSideUp()
          show which side of the die is currently up
 int roll()
          roll the die
 void setNumSides(int sides)
          Change the number of sides on the die
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NUM_SIDES

public static final int DEFAULT_NUM_SIDES
a constant for the number of sides by default

See Also:
Constant Field Values
Constructor Detail

Dice

public Dice()
Default constructor, creates a 6-sided die The die will initially be roll to give it a side up.


Dice

public Dice(int sides)
Constructor, creates a die with a number of sides specified by the input parameter The die will initially be roll to give it a side up.

Parameters:
sides - the number of sides on the die
Method Detail

roll

public int roll()
roll the die

Returns:
the number on the up side of the die after the roll

setNumSides

public void setNumSides(int sides)
Change the number of sides on the die

Parameters:
sides - The new number of sides the die will have

getNumSides

public int getNumSides()
View the number of sides on the die

Returns:
the number of sides on the die

getSideUp

public int getSideUp()
show which side of the die is currently up

Returns:
the number on the up side of the die from the last roll