ulfben

Random (android game dev)

Feb 26th, 2018
159
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×