// Ayaz Latif // 07/08/2020 // CSE142 // TA: Grace Hopper // Car lecture example // Produces an image of a black car with red wheels and a blue window on a grey background. /* DEVELOPMENT NOTES: ((Note: this is not something you should include in your own programs; this is included here to aid in your understanding and to provide additional context for the program.)) This was our second version of the program to create the image "van2" (which you can find in the the Web Comparison Tool) which contains two cars. To create this output, we created a parameterized method that could draw the car at the given location (via x, y coordinate parameters) */ import java.awt.*; public class Car2 { public static void main(String[] args) { DrawingPanel panel = new DrawingPanel(400, 200); Graphics g = panel.getGraphics(); panel.setBackground(Color.LIGHT_GRAY); drawCar(g, 10, 30); drawCar(g, 150, 10); } // draws a car with a black body, a blue window, and red wheels at the given loction. // Graphics g: the Graphics object to use when drawing // int x: the x-coordinate of the top-left corner of the drawn car // int y: the y-coordinate of the top-left corner of the drawn car public static void drawCar(Graphics g, int x, int y) { // draw body black rectange g.setColor(Color.BLACK); g.fillRect(x, y, 100, 50); // draw body black rectangle g.setColor(Color.CYAN); g.fillRect(x + 70, y + 10, 30, 20); // draw wheels red circles g.setColor(Color.RED); g.fillOval(x + 10, y + 40, 20, 20); g.fillOval(x + 70, y + 40, 20, 20); } }