// Tyler Rigsby, CSE 142 // Draws a simple boxy car. // This version shows method with x, y params. Will add size param next lecture. import java.awt.*; public class DrawCar { public static void main(String[] args) { DrawingPanel panel = new DrawingPanel(500, 500); panel.setBackground(Color.LIGHT_GRAY); Graphics g = panel.getGraphics(); drawCar(g, 10, 30); drawCar(g, 120, 120); for (int i = 0; i < 10; i++) { drawCar(g, 100 * i, 300); } } // Draws a car with the upper-left corner at the specified x, y // coordinate. public static void drawCar(Graphics g, int x, int y) { g.setColor(new Color(132, 240, 46)); 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); } }