|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectmegamek.common.MMRandom
public abstract class MMRandom
Used by Compute to generate random numbers, usually dice rolls. The base class is abstract, having a number of concrete subclasses that it will give using the generate() method.
| Nested Class Summary | |
|---|---|
(package private) static class |
MMRandom.CryptoRandom
Uses java.security.SecureRandom |
(package private) static class |
MMRandom.Pool36Random
Behaves like SunRandom for everything but d6(2) calls. |
(package private) static class |
MMRandom.SunRandom
Uses com.sun.java.util.collections.Random |
| Field Summary | |
|---|---|
static int |
R_CRYPTO
|
static int |
R_DEFAULT
|
static int |
R_POOL36
|
static int |
R_SUN
|
| Constructor Summary | |
|---|---|
MMRandom()
|
|
| Method Summary | |
|---|---|
(package private) Roll |
d6()
A single die |
(package private) Roll |
d6(int nDice)
Simulates six-sided die rolls. |
(package private) static MMRandom |
generate(int type)
Gives you the type asked for, defaulting to SunRandom if there are any errors. |
(package private) abstract int |
randomInt(int maxValue)
Returns a random int in the range from 0 to one less than
the supplied max 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 R_DEFAULT
public static final int R_SUN
public static final int R_CRYPTO
public static final int R_POOL36
| Constructor Detail |
|---|
public MMRandom()
| Method Detail |
|---|
static MMRandom generate(int type)
Roll d6(int nDice)
nDice - - the int number of dice to roll. If this
value is less than or equal to zero, an
IllegalArgumentException will be thrown.
Roll object containing the roll results.
IllegalArgumentException - will be thrown if the
input is <= 0.Roll d6()
abstract int randomInt(int maxValue)
int in the range from 0 to one less than
the supplied max value.
maxValue - - the smallest int value which will exceed
any random number returned by this method.
int from the value set [0, maxValue).
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||