import java.awt.Color;
import java.awt.Graphics;
public class Car{
private int _x, _y;
private int BODY_VERT_OFFSET = 50;
private int WIDTH = 200;
private int BODY_HEIGHT = WIDTH/4;
private int WINDSHIELD_DEPTH = WIDTH/4;
private int WHEEL_SIZE = 40;
public Car(int x, int y){
_x = x;
_y = y;
}
public void draw(Graphics g){
//be polite hold the old color
Color origColor = g.getColor();
g.setColor(Color.RED);//everyone needs a red car right?
//first lets draw the body of the car
g.drawRect(_x, _y+BODY_VERT_OFFSET, WIDTH, BODY_HEIGHT);
//now the top
g.setColor(Color.BLUE);
g.drawLine(_x, _y+BODY_VERT_OFFSET, _x+ WINDSHIELD_DEPTH, _y);
g.drawLine( _x+ WINDSHIELD_DEPTH, _y, _x+ WIDTH, _y);
g.drawLine( _x+ WIDTH, _y, _x+ WIDTH, _y + BODY_HEIGHT);
//now a wheel
g.drawOval(_x+WIDTH/4, _y+BODY_VERT_OFFSET+BODY_HEIGHT, WHEEL_SIZE, WHEEL_SIZE);
g.drawOval(_x+(WIDTH/4)*3, _y+BODY_VERT_OFFSET+BODY_HEIGHT, WHEEL_SIZE, WHEEL_SIZE);
//return the color
g.setColor(origColor);
}
}