Class Car
java.lang.Object
Vehicle
Car
- Direct Known Subclasses:
- Truck
public class Car
- extends Vehicle
A Car to drive down the road.
Constructor Summary |
Car()
Creates a new Car object. |
Method Summary |
void |
draw(Canvas canvas)
Draws the Car on the given Canvas |
void |
drive()
Drives the Car its speed, turning around if necessary. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
color
protected Color color
Car
public Car()
- Creates a new Car object.
draw
public void draw(Canvas canvas)
- Draws the Car on the given Canvas
- Overrides:
draw
in class Vehicle
- Parameters:
canvas
- The canvas on which to draw
drive
public void drive()
- Drives the Car its speed, turning around if necessary. The car changes color periodically as it drives.
- Overrides:
drive
in class Vehicle