产生随机数

import acm.program.ConsoleProgram;
import acm.util.RandomGenerator;

public class testProgram extends ConsoleProgram {
	private static final int PAUSE_TIME = 100; //暂停时间
	
	public void run() {
		while(true) {
			int x = rgen.nextInt(1,100); //产生 1 到 100 随即数
			println(x);
			if(x==99) break;
			pause(PAUSE_TIME); //暂停
		}
	}	
	private RandomGenerator rgen = RandomGenerator.getInstance(); 
}

你可能感兴趣的:(产生随机数)