Package rosequartz.rng
Class RandomNumberGenerator
java.lang.Object
rosequartz.rng.RandomNumberGenerator
Class used to generate random numbers.
-
Constructor Summary
ConstructorsConstructorDescriptionRandomNumberGenerator(long seed)Creates a random number generator from a seed to use. -
Method Summary
Modifier and TypeMethodDescriptionstatic doublegetDouble(double min, double max)Generates a completely random number and returns it as a double in the specified range.static floatgetFloat(float min, float max)Generates a completely random number and returns it as a float in the specified range.static intgetInt(int min, int max)Generates a completely random number and returns it as an integer in the specified range.longgetSeed()Gets the current seed used to generate from.doublenextDouble(double min, double max)Generates the next number and returns it as a double in the specified range.floatnextFloat(float min, float max)Generates the next number and returns it as a float in the specified range.intnextInt(int min, int max)Generates the next number and returns it as an integer in the specified range.setSeed(long seed)Sets the seed to generate from.
-
Constructor Details
-
RandomNumberGenerator
public RandomNumberGenerator(long seed)Creates a random number generator from a seed to use.- Parameters:
seed- the seed to generate from
-
-
Method Details
-
getInt
public static int getInt(int min, int max)Generates a completely random number and returns it as an integer in the specified range.- Parameters:
min- smallest possible resultmax- largest possible result- Returns:
- result
-
getFloat
public static float getFloat(float min, float max)Generates a completely random number and returns it as a float in the specified range.- Parameters:
min- smallest possible resultmax- largest possible result- Returns:
- result
-
getDouble
public static double getDouble(double min, double max)Generates a completely random number and returns it as a double in the specified range.- Parameters:
min- smallest possible resultmax- largest possible result- Returns:
- result
-
setSeed
Sets the seed to generate from.- Parameters:
seed- seed to use- Returns:
- this
-
getSeed
public long getSeed()Gets the current seed used to generate from.- Returns:
- current seed
-
nextInt
public int nextInt(int min, int max)Generates the next number and returns it as an integer in the specified range.- Parameters:
min- smallest possible resultmax- largest possible result- Returns:
- result
-
nextFloat
public float nextFloat(float min, float max)Generates the next number and returns it as a float in the specified range.- Parameters:
min- smallest possible resultmax- largest possible result- Returns:
- result
-
nextDouble
public double nextDouble(double min, double max)Generates the next number and returns it as a double in the specified range.- Parameters:
min- smallest possible resultmax- largest possible result- Returns:
- result
-