RandomNumberFactory.java 628B

123456789101112131415161718192021
  1. package com.zipcodewilmington.tools;
  2. import java.awt.*;
  3. import java.util.*;
  4. /**
  5. * Created by Leon on 2/4/2017.
  6. */
  7. public abstract class RandomNumberFactory {
  8. private static final Random random = new Random();
  9. /** @return a random float between the specified min and max numeric range */
  10. public static Float createFloat(float min, float max) {
  11. return random.nextFloat() * (max - min) + 1;
  12. }
  13. /** @return a random integer between the specified min and max numeric range */
  14. public static Integer createInteger(Integer min, Integer max) {
  15. return createFloat(min, max).intValue();
  16. }
  17. }