Class Car

java.lang.Object
  extended by Vehicle
      extended by Car
Direct Known Subclasses:
Truck

public class Car
extends Vehicle

A Car to drive down the road.


Field Summary
protected  Color color
           
 
Fields inherited from class Vehicle
facingRight, position, speed
 
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 Vehicle
turn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

color

protected Color color
Constructor Detail

Car

public Car()
Creates a new Car object.

Method Detail

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