// 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(500, 200); panel.setBackground(Color.LIGHT_GRAY); Graphics g = panel.getGraphics(); // Note: To use a special version of graphics to help you debug // Graphics g = panel.getDebuggingGraphics(); drawCar(g, 10, 30, 100); drawCar(g, 150, 10, 100); drawCar(g, 270, 140, 50); drawCar(g, 380, 80, 80); // Note: For special version of graphics to help you debug // System.out.println(panel.getCounts()); /* // 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); } }