List of usage examples for java.lang Math random
public static double random()
From source file:Main.java
public static int getPositon(int height) { int tempPositoin = (int) (Math.random() * height); if (tempPositoin < 20) { tempPositoin += 20;/*from ww w . ja v a2 s.c o m*/ } return tempPositoin; }
From source file:Main.java
public static int getPositon(int height) { int tempPositoin = (int) (Math.random() * height); if (tempPositoin < 25) { tempPositoin += 15;// ww w . ja va 2 s . c o m } //return tempPositoin; return height - 20; }
From source file:Main.java
public static void randomSleep() { try {//from ww w.j a v a2 s . c om Thread.sleep((long) (Math.random() * 3000)); } catch (InterruptedException e) { e.printStackTrace(); } }
From source file:Main.java
public static final float randomInRange(float min, float max) { return (float) (Math.random() < 0.5 ? ((1 - Math.random()) * (max - min) + min) : (Math.random() * (max - min) + min)); }
From source file:Main.java
private static String generateBrand() { Long result = Math.round(Math.random() * 2); switch (result.intValue()) { case 0://ww w . j av a 2 s.co m return "Heineken"; case 1: return "Grimbergen"; case 2: return "Kriek"; default: break; } return null; }
From source file:Main.java
public static int getRandomColor() { int red = (int) (Math.random() * 255); int green = (int) (Math.random() * 255); int blue = (int) (Math.random() * 255); return Color.rgb(red, green, blue); }
From source file:Main.java
public static char randomDecimalDigit() { return digits[(int) Math.floor(Math.random() * 10)]; }
From source file:Main.java
public static float genRand(float min, float max) { return (float) Math.random() * (max - min) + min; }
From source file:Main.java
public static int buildRandom(int length) { int num = 1;//from w w w. j a v a 2 s . co m double random = Math.random(); if (random < 0.1) { random = random + 0.1; } for (int i = 0; i < length; i++) { num = num * 10; } return (int) ((random * num)); }
From source file:Main.java
public static String getRandomString(int len) { String str = (Long.toHexString(Double.doubleToLongBits(Math.random()))).substring(0, len); return str;// w w w .j a v a 2 s. c om }