DEADSOFTWARE

Initial commit.
[LongFlight.git] / src / code / kalter / longflight / crypto / Random.java
1 package code.kalter.longflight.crypto;
3 /**
4 * Простой Генератор Псевдослучайных Чисел
5 *
6 * @author KalterFive
7 */
8 public class Random {
10 private int next;
12 public Random(int next) {
13 this.next = next;
14 }
16 public Random() {
17 this((int) System.currentTimeMillis());
18 }
20 public int random() {
21 next ^= (next << 13);
22 next ^= (next >>> 17);
23 next ^= (next << 5);
24 return Math.abs(next);
25 }
27 // random от [0] до [max - 1]
28 public int random(int max) {
29 return random() % max;
30 }
31 }