CHOICE - Choice typepublic final class JHelpRandom<CHOICE>
extends java.lang.Object
After each time you do Choice have 50% chance to be "A", After each time you do Choice have 55 chance of 142 to be "P" and 87 chance of 142 to be "R"| Modifier and Type | Class and Description |
|---|---|
private class |
JHelpRandom.Limit<ELEMENT>
A registered limit.
|
| Modifier and Type | Field and Description |
|---|---|
private java.util.ArrayList<JHelpRandom.Limit<CHOICE>> |
limits
Registered limits
|
private int |
maximum
Actual maximum
|
| Constructor and Description |
|---|
JHelpRandom()
Create a new instance of JHelpRandom
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChoice(int number,
CHOICE choice)
Add a choice
|
CHOICE |
choose()
Choose a value randomly
|
static <E extends java.lang.Enum> |
random(java.lang.Class<E> clas)
Choose a value of an enum
|
static int |
random(int limit)
Give a random value between 0 (include) and given limit (exclude)
|
static int |
random(int minimum,
int maximum)
Give random number inside an interval, each limit are includes
|
static <T> T |
random(T[] array)
Return an element of an array.
|
java.lang.String |
toString()
String representation
Parent documentation: |
private final java.util.ArrayList<JHelpRandom.Limit<CHOICE>> limits
private int maximum
public static final <E extends java.lang.Enum> E random(java.lang.Class<E> clas)
E - Enum to get a valueclas - Enum classnull if failedpublic static final int random(int limit)
limit - Limit to respectpublic static final int random(int minimum,
int maximum)
minimum - Minimum valuemaximum - Maximum valuepublic static final <T> T random(T[] array)
null is return is the array is null or emptyT - Type of array's elementarray - Array to get one elementnull if array null or emptypublic void addChoice(int number,
CHOICE choice)
number - Frequency of the choice (Can't be < 1)choice - The choicepublic CHOICE choose()
public java.lang.String toString()
toString in class java.lang.ObjectObject.toString()