/** @author Scott Marshall @author University of Glasgow, MSc IT Project 2001 @author Building an OnLine Course in Computing Fundamentals */ package ukacgla_ATT; import java.util.Random; /** Provides Random numbers for selecting logic gates. */ public class TTRandom{ private Random rng; private int output, output1, output2, output3; /** Generates a new Random number generator. Store generated numbers in integers 1,2 and 3 respectively. */ public TTRandom(){ rng = new Random(); } /** Generate 3 random numbers and store in integers 1,2 and 3 respectively. */ public void genRandom() { for(int j = 0 ; j < 5 ; j++){ for(int i = 0; i<3 ; i++){ output = rng.nextInt(5); switch (i) { case 0: output1 = output; break; case 1: output2 = output; break; case 2: output3 = output; break; } } }//ends j loop }//ends method /** Returns first random number generated */ public int getRandom1() { return output1; } /** Returns second random number generated */ public int getRandom2() { return output2; } /** Returns third random number generated */ public int getRandom3() { return output3; } }