foul-magics/Mage/src/main/java/mage/util/RandomUtil.java
2020-02-05 02:17:00 +04:00

43 lines
887 B
Java

package mage.util;
import java.awt.*;
import java.util.Random;
/**
* Created by IGOUDT on 5-9-2016.
*/
public final class RandomUtil {
private static Random random = new Random(); // thread safe with seed support
private RandomUtil() {
}
public static Random getRandom() {
return random;
}
public static int nextInt() {
return random.nextInt();
}
public static int nextInt(int max) {
return random.nextInt(max);
}
public static boolean nextBoolean() {
return random.nextBoolean();
}
public static double nextDouble() {
return random.nextDouble();
}
public static Color nextColor() {
return new Color(RandomUtil.nextInt(256), RandomUtil.nextInt(256), RandomUtil.nextInt(256));
}
public static void setSeed(long newSeed) {
random.setSeed(newSeed);
}
}