Class Car

java.lang.Object
  |
  +--Vehicle
        |
        +--Car

public class Car
extends Vehicle

A Car is a kind of Vehicle that occupies a single location on the traffic grid.

Version:
1.0
Author:
David Matuszek

Field Summary
 
Fields inherited from class Vehicle
currentColumn, currentRow, destinations, goalColumn, goalRow, town
 
Constructor Summary
(package private) Car(Vehicle[][] town, java.lang.String[][] destinations, int row, int column)
          Constructs a Car.
 
Method Summary
(package private)  boolean onDestination()
          Tests if this Car is at its destination.
(package private)  boolean tryMove(int rowChange, int columnChange)
          Tries to move this Car one step closer to its destination, and returns true if successful.
 
Methods inherited from class Vehicle
alreadyTaken, disappear, manhattanDistance, manhattanDistance, move, sign, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Car

Car(Vehicle[][] town,
    java.lang.String[][] destinations,
    int row,
    int column)
Constructs a Car.

Parameters:
town - The traffic grid on which to place this Car.
destinations - The array in which to indicate this Car's destination.
row - The row at which to place this Car.
column - The column at which to place this Car.
Method Detail

tryMove

boolean tryMove(int rowChange,
                int columnChange)
Tries to move this Car one step closer to its destination, and returns true if successful. Note that this method has the side effect of actually moving this Car, if the move is possible.

Specified by:
tryMove in class Vehicle
Parameters:
rowChange - The amount to add to this Car's row.
columnChange - The amount to add to this Car's column.
Returns:
True if this Car has been moved.

onDestination

boolean onDestination()
Tests if this Car is at its destination.

Specified by:
onDestination in class Vehicle
Returns:
True if this Car is at its destination.