Class Roller

java.lang.Object
  extended by Roller

public class Roller
extends java.lang.Object

A class acting as a container for one or more Die objects. An object of this type allows you to easily roll all, or a subset, of the Die objects it contains with one method call. The Class also provides constructors that allow a user to specify seed values for the Die to allow reproducable behavior for easy testing, debugging, and or cheating (not recommended!) at dice games.


Constructor Summary
Roller(int numberOfDie)
          Creates a new instance of Roller with the specified number of die.
Roller(int numberOfDie, int numberOfSides)
          Creates a new instance of Roller with the specified number of die having the specified number of sides.
Roller(int numberOfDie, int numberOfSides, long[] seeds)
          Creates a new instance of Roller with the specified number of die having the specified number of sides, and using the provided seed values for each one.
Roller(int numberOfDie, long[] seeds)
          Creates a new instance of Roller with the specified number of die using the provided seed values for each one.
 
Method Summary
 int[] roll()
          Rolls all of the die and returns the value of each in an array of integers.
 int[] roll(int numberOfDice)
          Rolls the specified number of die and returns the value of each in an array of integers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Roller

public Roller(int numberOfDie)
Creates a new instance of Roller with the specified number of die.

Parameters:
numberOfDie - The number of die contained by this Roller. The value must be a positive integer.

Roller

public Roller(int numberOfDie,
              int numberOfSides)
Creates a new instance of Roller with the specified number of die having the specified number of sides.

Parameters:
numberOfDie - The number of die contained by this Roller. The value must be a positive integer.
numberOfSides - The number of sides each die in this Roller will have. The value must be a positive integer.

Roller

public Roller(int numberOfDie,
              long[] seeds)
Creates a new instance of Roller with the specified number of die using the provided seed values for each one. The first seed should be used with first die, the second seed with the second die, and so forth.

Parameters:
numberOfDie - The number of die contained by this Roller. The value must be a positive integer.
seeds - An array of values to use to seed each die. The size of the array must be greater than or equal to the number of die being created.

Roller

public Roller(int numberOfDie,
              int numberOfSides,
              long[] seeds)
Creates a new instance of Roller with the specified number of die having the specified number of sides, and using the provided seed values for each one. The first seed should be used with first die, the second seed with the second die, and so forth.

Parameters:
numberOfDie - The number of die contained by this Roller. The value must be a positive integer.
numberOfSides - The number of sides each die in this Roller will have. The value must be a positive integer.
seeds - An array of values to use to seed each die. The size of the array must be greater than or equal to the number of die being created.
Method Detail

roll

public int[] roll()
Rolls all of the die and returns the value of each in an array of integers.

Returns:
An array of integers representing the value of each die after rolling. The size of the array will be equal the the number of die rolled.

roll

public int[] roll(int numberOfDice)
Rolls the specified number of die and returns the value of each in an array of integers.

Parameters:
numberOfDice - The number of die to roll, must between 1 and the number of die contained by this Roller, inclusive.
Returns:
An array of integers representing the value of each die after rolling. The size of the array will be equal the the number of die rolled.