Code example for Random

0
/** 
 * Utility class that returns random quantities. 
 */ 
public class RandomQuantityGenerator implements QuantityGenerator { 
 
  private final Random _random = new Random();
  private final int _granularity;
  private final int _range;
 
  public RandomQuantityGenerator(final int granularity, final int range) {
    ArgumentChecker.isTrue(granularity > 0, "granularity");
    ArgumentChecker.isTrue(range > 0, "range");
    _granularity = granularity;
    _range = range;
  } 
 
  protected int getGranularity() { 
    return _granularity;
  } 
 
  protected int getRange() {