// CSE 142 Autumn 2007, Marty Stepp // This program draws two car figures at different positions. import java.awt.*; // so I can use Graphics public class DrawCar { public static void main(String[] args) { DrawingPanel panel = new DrawingPanel(300, 200); panel.setBackground(Color.LIGHT_GRAY); Graphics g = panel.getGraphics(); // g x y drawCar(g, 10, 30); drawCar(g, 150, 10); } // This method draws one car figure with the given position. public static void drawCar(Graphics g, int x, int y) { g.setColor(Color.BLACK); g.fillRect(x, y, 100, 50); 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); } }