package edu.hust.imageviewer.util;
import java.util. Random;
/**
* RandomGenerator is a generator for random in the system,<br />
* the default seed is the tms of the system.
* @author quickpoint
* @version 1.0 2006-05-01
*/
public class RandomGenerator {
// random generator
private static Random random = new Random( System.currentTimeMillis());
/**
* Constructor
*/
private RandomGenerator() {
// nothing
}
/**
* Set seed
* @param aSeed a seed provided.
*/
public static void setSeed( long aSeed ) {
random = new Random( aSeed );
}
/**
* Generate an integer
* @return integer random number
*/
public static int nextInt() {
return random.nextInt();
}
/**
* Generate an integer with scope
* @return integer random number within the scope
*/
public static int nextInt( int scope) {
return random.nextInt( scope );
}
/**
* Generate a long
* @return long random number
*/
public static long nextLong() {
return random.nextLong();
}
}
import java.util. Random;
/**
* RandomGenerator is a generator for random in the system,<br />
* the default seed is the tms of the system.
* @author quickpoint
* @version 1.0 2006-05-01
*/
public class RandomGenerator {
// random generator
private static Random random = new Random( System.currentTimeMillis());
/**
* Constructor
*/
private RandomGenerator() {
// nothing
}
/**
* Set seed
* @param aSeed a seed provided.
*/
public static void setSeed( long aSeed ) {
random = new Random( aSeed );
}
/**
* Generate an integer
* @return integer random number
*/
public static int nextInt() {
return random.nextInt();
}
/**
* Generate an integer with scope
* @return integer random number within the scope
*/
public static int nextInt( int scope) {
return random.nextInt( scope );
}
/**
* Generate a long
* @return long random number
*/
public static long nextLong() {
return random.nextLong();
}
}