001package components.random; 002 003/** 004 * {@code Random} represented as a {@link java.util.Random java.util.Random} 005 * with implementations of all methods. 006 */ 007public class Random1L implements Random { 008 009 /* 010 * Private members -------------------------------------------------------- 011 */ 012 013 /** 014 * The pseudo-random number generator. 015 */ 016 private java.util.Random rep = new java.util.Random(); 017 018 /* 019 * Public members --------------------------------------------------------- 020 */ 021 022 @Override 023 public final double nextDouble() { 024 return this.rep.nextDouble(); 025 } 026 027 @Override 028 public final int nextInt() { 029 double x = this.rep.nextDouble(); 030 long f = (long) Integer.MAX_VALUE - Integer.MIN_VALUE + 1; 031 return (int) (Math.floor(f * x) + Integer.MIN_VALUE); 032 } 033 034}