Package net.guizhanss.guizhanlib.utils
Class RandomUtil
java.lang.Object
net.guizhanss.guizhanlib.utils.RandomUtil
Utility methods about random numbers.
- Author:
- ybw0014
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doublerandomDouble(double min, double max) Get a randomDoublebetween min (inclusive) and max (inclusive).static intrandomInt(int min, int max) Get a randomIntegerbetween min (inclusive) and max (inclusive).static booleantestChance(int chance, int bound) Test chance of chance / bound.
-
Constructor Details
-
RandomUtil
public RandomUtil()
-
-
Method Details
-
randomInt
public static int randomInt(int min, int max) Get a randomIntegerbetween min (inclusive) and max (inclusive).- Parameters:
min- The minimum range.max- The maximum range.- Returns:
- The random
Integer
-
randomDouble
public static double randomDouble(double min, double max) Get a randomDoublebetween min (inclusive) and max (inclusive).- Parameters:
min- The minimum range.max- The maximum range.- Returns:
- The random
Double
-
testChance
public static boolean testChance(int chance, int bound) Test chance of chance / bound.- Parameters:
chance- Numerator (must be greater than 0)bound- Denominator (must be greater than 0)- Returns:
- If the roll succeed.
-