public class Dice extends Object
Modifier and Type | Field and Description |
---|---|
private int |
addition
Addition to the dice (negative = subtraction).
|
private int |
multiplier
Multiplier to the dice (negative = divisor).
|
private int |
number
Number of dice.
|
private static Random |
random
Random number generator.
|
private int |
sides
Sides on the dice.
|
Constructor and Description |
---|
Dice(Dice d)
Constructor (copy).
|
Dice(int sides)
Constructor (one die only).
|
Dice(int num,
int sides)
Constructor (number, sides).
|
Dice(int num,
int sides,
int add)
Constructor (number, sides, addition).
|
Dice(int number,
int sides,
int mul,
int add)
Constructor (all fields).
|
Dice(String s)
Constructor (read from string descriptor).
|
Modifier and Type | Method and Description |
---|---|
int |
getAdd() |
int |
getMul() |
int |
getNum() |
int |
getSides() |
static void |
initialize()
Initialize the dice random generator.
|
static void |
main(String[] args)
Main test function.
|
int |
maxRoll()
Compute the maximum possible roll.
|
String |
reportRoll()
Get a string description of a roll.
|
int |
roll()
Rolls the dice.
|
static int |
roll(int sides)
Roll one die from a static context.
|
int |
rollPlus(int modifier)
Rolls the dice with added modifier.
|
void |
setAdd(int add) |
void |
setMul(int mul) |
void |
setNum(int num) |
void |
setSides(int sides) |
String |
toString()
Identify this object as a string.
|
private int number
private int sides
private int multiplier
private int addition
private static Random random
Dice(int sides)
Dice(int num, int sides)
Dice(int num, int sides, int add)
Dice(int number, int sides, int mul, int add)
Dice(String s)
public Dice(Dice d)
public int getNum()
public int getSides()
public int getMul()
public int getAdd()
public void setNum(int num)
public void setSides(int sides)
public void setMul(int mul)
public void setAdd(int add)
public static void initialize()
public static int roll(int sides)
public int roll()
public int rollPlus(int modifier)
public int maxRoll()
public String toString()
public String reportRoll()
public static void main(String[] args)