|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectRollingDie
public class RollingDie
RollingDie class Instantiable class whose instances model playing dice; rolling a die results in a pseudorandom int between 1 and the number of sides being assigned as the face value; RollingDie instances have 6 sides by default; a different number of sides may also be specified. Sergio A. Alvarez, Oct. 2005.
Field Summary | |
---|---|
static int |
DEFAULT_NUM_SIDES
|
Constructor Summary | |
---|---|
RollingDie()
default constructor, constructs a 6-sided die. |
|
RollingDie(int numSides)
constructs a die with a specified number of sides. |
Method Summary | |
---|---|
int |
getFace()
returns the face currently showing on this die; does not roll die. |
javax.swing.ImageIcon |
getIcon()
returns an image of the face currently showing on this die. |
int |
roll()
pseudorandomly assigns a face value between 1 and the number of sides; returns the resulting face value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_NUM_SIDES
Constructor Detail |
---|
public RollingDie(int numSides)
numSides
- the desired number of sides of this instancepublic RollingDie()
Method Detail |
---|
public int roll()
public int getFace()
public javax.swing.ImageIcon getIcon()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |