public class Randomizer
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.Random |
theInstance |
Constructor and Description |
---|
Randomizer() |
Modifier and Type | Method and Description |
---|---|
static java.util.Random |
getInstance() |
static boolean |
nextBoolean()
Return a random boolean value.
|
static boolean |
nextBoolean(double probability)
This method simulates a weighted coin flip which will return
true with the probability passed as a parameter.
|
static java.lang.String |
nextColor()
Return a random color.
|
static double |
nextDouble()
Return a random double between 0 and 1.
|
static double |
nextDouble(double min,
double max)
Return a random double between min and max.
|
static int |
nextInt()
This method returns a random integer.
|
static int |
nextInt(int n)
This method returns a random integer between 0 and n, exclusive.
|
static int |
nextInt(int min,
int max)
Return a number between min and max, inclusive.
|
public static java.util.Random getInstance()
public static boolean nextBoolean()
public static boolean nextBoolean(double probability)
probability
- The probability that the method returns true, a value between 0 to 1 inclusive.public static int nextInt()
public static int nextInt(int n)
n
- The maximum value for the range.public static int nextInt(int min, int max)
min
- The minimum integer value of the range, inclusive.max
- The maximum integer value in the range, inclusive.public static double nextDouble()
public static double nextDouble(double min, double max)
min
- The minimum double value in the range.max
- The maximum double value in the rang.public static java.lang.String nextColor()