// CSE 142, Spring 2010, Marty Stepp // This program draws two car figures at different coordinates. // It demonstrates drawing with parameterized methods. import java.awt.*; public class Car { public static void main(String[] args) { DrawingPanel panel = new DrawingPanel(300, 200); Graphics g = panel.getGraphics(); car(g, 10, 30); car(g, 150, 10); } public static void car(Graphics g, int x, int y) { g.setColor(Color.BLACK); g.fillRect(x, y, 100, 50); // (10, 30) g.setColor(Color.RED); g.fillOval(x + 10, y + 40, 20, 20); g.fillOval(x + 70, y + 40, 20, 20); g.setColor(Color.CYAN); g.fillRect(x + 70, y + 10, 30, 20); } }