RandomNumberFactory.java 638B

1234567891011121314151617181920212223
  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. {
  12. return random.nextFloat() * (max - min) + min;
  13. }
  14. /** @return a random integer between the specified min and max numeric range */
  15. public static Integer createInteger(Integer min, Integer max)
  16. {
  17. return createFloat(min, max).intValue();
  18. }
  19. }