Class Dice

java.lang.Object
  extended byDice

public class Dice
extends java.lang.Object

This is a sample class that simulates a 6 sided die


Constructor Summary
Dice()
          The default constructor builds a 6-sided die
Dice(int sides)
          The constructor builds a die of the correct number of sides
 
Method Summary
 int getLastRoll()
          The getLastRoll method will return the last roll of the die
 int getSides()
          The getSides method will return the number of sides on the die
 int rollDie()
          The rollDie method returns a random number from 1 to numSides
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dice

public Dice(int sides)
The constructor builds a die of the correct number of sides

Parameters:
sides - the number of sides on the created dice

Dice

public Dice()
The default constructor builds a 6-sided die

Method Detail

rollDie

public int rollDie()
The rollDie method returns a random number from 1 to numSides

Returns:
the random value rolled

getLastRoll

public int getLastRoll()
The getLastRoll method will return the last roll of the die

Returns:
the value of from the last time we rolled

getSides

public int getSides()
The getSides method will return the number of sides on the die

Returns:
the number of sides on this die