moka.util
Class Random

java.lang.Object
  |
  +--moka.lang.Object
        |
        +--moka.util.Random

public class Random
extends Object

An instance of this class is used to generate a stream of pseudorandom numbers.

Since:
MDK1.01a

Field Summary
 short seed
          The state associated with this pseudorandom number generator.
 
Constructor Summary
Random()
          Creates a new random number generator.
Random(short seed)
          Creates a new random number generator using a single short seed.
 
Method Summary
 boolean nextBoolean()
          Generates the next pseudorandom boolean number.
 void nextBytes(moka.util.BYTE_p bytes, short num)
          Generates random bytes and places them into a user-supplied byte array.
 double nextDouble()
          Generates the next pseudorandom double number.
 short nextShort()
          Generates the next pseudorandom short number.
 
Methods inherited from class moka.lang.Object
equals, finalize, getClassName, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

seed

public short seed
The state associated with this pseudorandom number generator.

Constructor Detail

Random

public Random()
Creates a new random number generator. Its seed is initialized to a value based on the current time Two Random objects created within the same millisecond will have the same sequence of random numbers.


Random

public Random(short seed)
Creates a new random number generator using a single short seed.

Parameters:
seed - the initial seed.
Method Detail

nextShort

public short nextShort()
Generates the next pseudorandom short number.

Returns:
the next pseudorandom value from this random number generator's sequence.

nextDouble

public double nextDouble()
Generates the next pseudorandom double number.

Returns:
the next pseudorandom value from this random number generator's sequence.

nextBoolean

public boolean nextBoolean()
Generates the next pseudorandom boolean number.

Returns:
the next pseudorandom value from this random number generator's sequence.

nextBytes

public void nextBytes(moka.util.BYTE_p bytes,
                      short num)
Generates random bytes and places them into a user-supplied byte array. The number of random bytes produced is equal to the specified number.

Parameters:
bytes - the non-null byte array in which to put the random bytes.
num - the number of random bytes to produce