public class CarShape extends java.lang.Object implements MoveableShape
Modifier and Type | Field and Description |
---|---|
private int |
width |
private int |
x |
private int |
y |
Constructor and Description |
---|
CarShape(int x,
int y,
int width)
Constructs a car item.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(java.awt.Graphics2D g2)
Draws the shape.
|
void |
translate(int dx,
int dy)
Moves the shape by a given amount.
|
public CarShape(int x, int y, int width)
x
- the left of the bounding rectangley
- the top of the bounding rectanglewidth
- the width of the bounding rectanglepublic void translate(int dx, int dy)
MoveableShape
translate
in interface MoveableShape
dx
- the amount to translate in x-directiondy
- the amount to translate in y-directionpublic void draw(java.awt.Graphics2D g2)
MoveableShape
draw
in interface MoveableShape
g2
- the graphics context