










































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











































public class SimpleDraw { /* ... stuff ... / public static void main ( String args []) { SimpleDraw content = new SimpleDraw (new DrawGraphics ()); / ... more stuff ... */ } }
public class DrawGraphics { BouncingBox box ; public DrawGraphics () { box = new BouncingBox ( 200 , 50 , Color. RED ); } public void draw ( Graphics surface ) { surface. drawLine ( 50 , 50 , 250 , 250 ); box. draw ( surface ); } }
public class DrawGraphics { BouncingBox box; // a field or member variable public DrawGraphics () { box = new BouncingBox ( 200 , 50 , Color. RED ); } public void draw ( Graphics surface ) { surface. drawLine ( 50 , 50 , 250 , 250 ); box. draw ( surface ); } }
public class DrawGraphics { public void draw ( Graphics surface ) { surface. drawLine ( 50 , 50 , 250 , 250 ); box. draw ( surface ); surface. fillRect ( 150 , 100 , 25 , 40 ); surface. fillOval ( 40 , 40 , 25 , 10 ); surface. setColor ( Color. YELLOW ); surface. drawString ( "Mr. And Mrs. Smith" , 200 , 10 ); } }
public class DrawGraphics { ArrayList < BouncingBox > boxes = new ArrayList < BouncingBox >(); public DrawGraphics () { boxes. add (new BouncingBox ( 200 , 50 , Color. RED )); boxes. add (new BouncingBox ( 10 , 10 , Color. BLUE )); boxes. add (new BouncingBox ( 100 , 100 , Color. GREEN )); boxes. get ( 0 ). setMovementVector ( 1 , 0 ); boxes. get ( 1 ). setMovementVector (- 3 , - 2 ); boxes. get ( 2 ). setMovementVector ( 1 , 1 ); } public void draw ( Graphics surface ) { for ( BouncingBox box : boxes ) { box. draw ( surface ); } } }
SimpleDraw DrawGraphics ArrayList BouncingBox BouncingBox BouncingBox