SHARE
TWEET

Random (android game dev)

ulfben Feb 26th, 2018 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top