Advertisement
ulfben

Random (android game dev)

Feb 26th, 2018
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. public class Random {
  2.     private final static java.util.Random RNG = new java.util.Random();
  3.     private Random(){super();}
  4.  
  5.     public static boolean coinFlip(){
  6.         return RNG.nextFloat() > 0.5;
  7.     }
  8.  
  9.     public static float nextFloat(){
  10.         return RNG.nextFloat();
  11.     }
  12.  
  13.     public static int nextInt(final int max){
  14.         return RNG.nextInt(max);
  15.     }
  16.  
  17.     public static int between(final int min, final int max){
  18.         return RNG.nextInt(max-min)+min;
  19.     }
  20.  
  21.     public static float between(final float min, final float max){
  22.         return min+RNG.nextFloat()*(max-min);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement