interface ICommand { void execute(int x); } class Client { ICommand c; void setCommand(ICommand c) { this.c = c; } void run(int i){ // Math.random() returns a double between >=0.0 and < 1.0 int j = (int) (10.0*Math.random()); if(i > j) { System.out.println(i+" > "+j); c.execute(j); } else { System.out.println(i+" < "+j); } } } class Command1 implements ICommand { public void execute(int x) { System.out.println("Yahoo! " + x); } } class Command2 implements ICommand { public void execute(int x) { System.out.println("Mamma mia!" + x); } } class CommandFrame extends javax.swing.JFrame implements ICommand { public void execute(int x) { int y = 100*x; // will need this value many times setTitle("The frame is "+y+" x "+y+" pixels"); // sets the title of the frame setSize(y,y); // sets the size of the square frame show(); // show the frame if not visible } } class PhraseMaker { void phrase1() { System.out.println("Java: More fun under the Sun."); } void phrase2() { System.out.println("C#: Bill G's vision when he gets old?"); } }