Class Vehicle

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

public class Vehicle
extends Object

A Vehicle that can drive and turn down the road.


Field Summary
protected  boolean facingRight
           
protected  int position
           
protected  int speed
           
 
Constructor Summary
Vehicle()
          Creates a new Vehicle object.
 
Method Summary
 void draw(Canvas canvas)
          Draws the vehicle on the given canvas.
 void drive()
          Drives the vehicle its speed, turning around if necessary.
 void turn()
          Turns the vehicle around.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

facingRight

protected boolean facingRight

position

protected int position

speed

protected int speed
Constructor Detail

Vehicle

public Vehicle()
Creates a new Vehicle object.

Method Detail

draw

public void draw(Canvas canvas)
Draws the vehicle on the given canvas. Acts as an abstract method--Vehicles cannot inherently be drawn.

Parameters:
canvas - The canvas on which to draw

drive

public void drive()
Drives the vehicle its speed, turning around if necessary.


turn

public void turn()
Turns the vehicle around.