Random.java 913 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package utility;
  2. public class Random {
  3. private static java.util.Random random = new java.util.Random();
  4. /**
  5. * True or false
  6. * @return the random boolean.
  7. */
  8. public static boolean nextBoolean(){
  9. return random.nextBoolean();
  10. }
  11. /**
  12. * Between 0.0(inclusive) and 1.0 (exclusive)
  13. * @return the random double.
  14. */
  15. public static double nextDouble() {
  16. return random.nextDouble();
  17. }
  18. public static float nextFloatInRange(float min, float max) {
  19. return min + random.nextFloat() * Math.abs(max - min);
  20. }
  21. public static double nextDoubleInRange(double min, double max) {
  22. return min + random.nextDouble() * Math.abs(max - min);
  23. }
  24. /**
  25. * Random Int in Range [min;max[ with UniformDistirbution
  26. * @param min
  27. * @param max
  28. * @return
  29. */
  30. public static int nextIntegerInRange(int min, int max) {
  31. return min + random.nextInt(max - min);
  32. }
  33. }