// Allison Obourn, CSE 142 // Draws cars of different sizes in different positions. import java.awt.*; // (to use Graphics, Color) public class DrawCar { public static void main(String[] args) { DrawingPanel panel = new DrawingPanel(400, 400); panel.setBackground(Color.LIGHT_GRAY); Graphics g = panel.getGraphics(); drawCar(g, 10, 30, 100); drawCar(g, 150, 10, 50); } // draws a car that is size wide with the top left corner at x, y public static void drawCar(Graphics g, int x, int y, int size) { g.setColor(Color.BLACK); g.fillRect(x, y, size, size / 2); g.setColor(Color.RED); g.fillOval(x + size /10, y + size / 2 - size / 10, size / 5, size / 5); g.fillOval(x + 7 * size / 10, y + size / 2 - size / 10, size / 5, size / 5); g.setColor(Color.CYAN); g.fillRect(x + 7 * size / 10, y + size / 10, 3 * size / 10, size / 5); } }