// Dr. Dale // August 20, 2019 // Homework #0: Good Coding Standards through Ch2 // Each mouse press moves a pair of glasses to the right // Each exit resets by moving glasses back to start; ready to move import objectdraw.*; import java.awt.*; public class MovingSpecsClient extends WindowController{ public static void main(String[]args){ new MovingSpecsClient().startController(800,250); } // glasses frames made of a thicker 'brow' over each eye & a bridge piece private FilledRect eyeLeft,eyeRight,bridge; // each bit of 'glass' is surrounded by a frame as well. // use two ovals each to make each just a bit thicker... private FramedOval left1, left2, right1,right2; public void begin(){ // although user has been told 'clicking' makes things happen, // implementation will actually use a press to make it run more smoothly Text msg1 = new Text("Clicking makes things happen.", 10,10,canvas); Text msg2 = new Text("Exiting will reset." , 10,40,canvas); msg1.setFontSize( 20 ); msg2.setFontSize( 20 ); msg1.setColor( Color.BLUE ); msg2.setColor( Color.BLUE ); 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 by // clearing the canvas // calling begin method, explicitly this time! public void onMouseExit(Location p){ canvas.clear(); begin(); } }