// Dr. Dale // August 20, 2019 // Homework #0: Good Coding Standards through Ch2 // Each mouse press moves a pair of glasses to the right // Exit resets. import objectdraw.*; import java.awt.*; public class Ch2Client extends WindowController{ public static void main(String[]args){ new Ch2Client().startController(800,800); } // glasses frames private FilledRect eyeLeft,eyeRight,bridge; private FramedOval left1, left2, right1, right2; public void begin(){ // instructions (show tabs) new Text("Clicking makes things happen. Exit to reset.", 10,10,canvas); // construct frames eyeLeft = new FilledRect( 55, 80, 50, 5, canvas); left1 = new FramedOval( 50, 80, 60,50, canvas); left2 = new FramedOval( 51, 81, 58,48, canvas); eyeRight = new FilledRect( 125, 80, 50, 5,canvas); right1 = new FramedOval( 120, 80, 60, 50, canvas); right2 = new FramedOval( 121, 81, 58, 48, canvas); bridge = new FilledRect( 105, 100, 20, 5, canvas); } public void onMousePress(Location p){ eyeLeft.move( 10, 0 ); left1.move( 10, 0 ); left2.move( 10, 0 ); eyeRight.move( 10, 0 ); right1.move( 10, 0 ); right2.move( 10, 0 ); bridge.move( 10, 0 ); } // reset public void onMouseExit(Location p){ canvas.clear(); begin(); } }