org.jtools.common.utils
Class RandomGenerator

java.lang.Object
  extended byorg.jtools.common.utils.RandomGenerator

public class RandomGenerator
extends java.lang.Object

 Simple Random Generator class
 

Version:
$Id: RandomGenerator.java,v 1.2 2002/07/27 17:57:42 placson Exp $
Author:
Patrick Lacson (patrick@lacson.org)

Constructor Summary
RandomGenerator()
          Constructor that initializes the RandomGenerator
 
Method Summary
 int getNext(int seed)
          Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.
 int getNext(int low, int high)
          Returns a pseudorandom, uniformly distributed int value between low and high, drawn from this random number generator's sequence.
 java.lang.Object getRandomItem(java.util.ArrayList list)
          Returns a randomly selected element from the ArrayList
 java.lang.String getStringItem(java.util.ArrayList list)
          Returns a randomly selected element from the ArrayList that is converted to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomGenerator

public RandomGenerator()
Constructor that initializes the RandomGenerator

Method Detail

getNext

public int getNext(int seed)
Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.


getNext

public int getNext(int low,
                   int high)
Returns a pseudorandom, uniformly distributed int value between low and high, drawn from this random number generator's sequence.

Parameters:
high - the highest number allowed
low - the lowest number allowd

getRandomItem

public java.lang.Object getRandomItem(java.util.ArrayList list)
Returns a randomly selected element from the ArrayList

Parameters:
list - An ArrayList containing the list of elements

getStringItem

public java.lang.String getStringItem(java.util.ArrayList list)
Returns a randomly selected element from the ArrayList that is converted to a String.

Parameters:
list - An ArrayList containing the list of elements