import java.util.Random; /* This class was copied in its entirety from the book "Object Oriented Design and Patterns" by Cay Horstmann. Only some variable names were changed and a output messages were added to help trace the output. */ public class SingleRandom { private Random generator; private static SingleRandom instance = new SingleRandom (); private SingleRandom () { System.out.println(">>> Trace only: this.SingleRandom() <<<"); generator = new Random (); } public void setSeed (int seed) { System.out.println(">>> Trace only: ref.setSeed() <<<"); generator.setSeed(seed); } public int nextInt () { System.out.println(">>> Trace only: ref.nextInt() <<<"); return (generator.nextInt()); } public static SingleRandom getInstance () { System.out.println(">>> Trace only: SingleRandom.getInstance() <<<"); return instance; } }