import element.*; public class Loops { public static void main(String args[]) { DrawingWindow d = new DrawingWindow(); ConsoleWindow c = new ConsoleWindow(); Pt releasePoint; int counter,target,guess; c.out.println("Should print 3,2,1:"); counter = 3; while (counter > 0) { c.out.println(counter); counter--; } c.out.println("Should print 3,2,1:"); counter = 3; // counter is 3 c.out.println(counter); counter--; // counter is now 2 c.out.println(counter); counter--; // counter is now 1 c.out.println(counter); counter--; // counter is now 0 c.out.println("Press the mouse."); while (!d.mousePressed()); c.out.println("Fine."); c.out.println("Should print 3."); target = 3; while (!d.mousePressed()) { target = 42; } c.out.println(target); c.out.println(target); c.out.println("Should print 42."); do { target = 42; } while (!d.mousePressed()); c.out.println(target); c.out.println("You may now let go of the mouse."); d.awaitMouseRelease(); c.out.println("Cool."); c.out.println("Type in a negative number, should retry."); do { c.out.println("I'm thinking of a number between 1 and 100"); c.out.println("What do you think it is?"); guess = c.input.readInt(); } while ((guess < 1) || (guess > 100)); c.out.println("Fine."); c.out.println("Click on the center of the window."); do { releasePoint = d.getMouse(); } while (!d.mousePressed()); c.out.println("Center is about "+releasePoint); System.exit(0); } }