/* 
 *      Copyright (c) 1997-98 
 *      NorthEast Parallel Architectures Center, Syracuse University. 
 * All Rights Reserved. Permission to use, copy, modify, and distribute this
 * software and its documentation for educational, research and non-profit
 * purposes, without fee, and without a written agreement is hereby granted,
 * provided that the above copyright notice and this paragraph appear in all
 * copies. Permission to incorporate this software into commercial products may
 * be obtained by contacting the NorthEast Parallel Architectures Center. 
 *
 * The software program and documentation are supplied "as is",
 * without any accompanying services from NPAC. NPAC does not
 * warrant that the operation of the program will be uninterrupted or
 * error-free. The end-user understands that the program was developed for
 * research purposes and is advised not to rely exclusively on the program for
 * any reason.
 *
 */

package cis600.impl;

import cis600.util.*;
import java.util.Random;


public class RandomGenImpl extends cis600.util._RandomGenImplBase {
  /** Construct a persistently named object. */
  public RandomGenImpl(java.lang.String name) {
    super(name);
  }

  /** Construct a transient object. */
  public RandomGenImpl() {
    super();
  }

   /**
   * Generates an int value between 1 and the given limit.
   * @param hi The upper bound.
   * @return An integer value.
   * @see java.util.Random#nextInt
   **/
  public int nextInt( int hi ) {
    return ((int) Math.abs(Math.random() * ( hi + 1 )) );
  }

  /**
   * Generates an int value between the given limits.
   * @param lo The lower bound.
   * @param hi The upper bound.
   * @return An integer value.
   * @throws InvalidOperationException Invalid Operation due to limits
   * @see java.util.Random#nextInt
   **/
  public int nextIntInRange( int lo, int hi ) 
       throws InvalidOperationException {
     if ( lo > hi )
       throw new InvalidOperationException("invalid range:"+ lo + " > " + hi );
     return ((int) Math.abs(Math.random() * ( hi - lo + 1 )) ) + lo;
  }
}