// Zorah Fung, CSE 142 // Draws cars of different sizes and positions import java.awt.*; public class CarFinal { public static void main(String[] args) { DrawingPanel panel = new DrawingPanel(400, 100); panel.setBackground(Color.LIGHT_GRAY); Graphics brush = panel.getGraphics(); drawCar(brush, 10, 30, 100); drawCar(brush, 150, 10, 50); drawCar(brush, 280, 20, 80); /* // Animates a car that drives across the screen for (int i = 0; i < 75; i++) { drawCar(g, 10 + 10 * i, 30, 50); panel.sleep(30); panel.clear(); } */ } // Note: Your method comments should describe what each parameter represents. // Draws a black car with its top left corner at the given x and y value // and a width of the given size public static void drawCar(Graphics g, int x, int y, int size) { // car body g.setColor(Color.BLACK); g.fillRect(x, y, size, size / 2); // wheels g.setColor(Color.RED); g.fillOval(x + size / 10, y + 2 * size / 5, size / 5, size / 5); g.fillOval(x + (7 * size / 10), y + 2 * size / 5, size / 5, size / 5); // window g.setColor(Color.CYAN); g.fillRect(x + 7 * size / 10, y + size / 10, 3 * size / 10, size / 5); } }