Class LocatedVehicle

java.lang.Object
  |
  +--Vehicle
        |
        +--LocatedVehicle
All Implemented Interfaces:
java.lang.Comparable, Locatable
Direct Known Subclasses:
TransitBus

public class LocatedVehicle
extends Vehicle
implements Locatable

This class implements the ability to give a Vehicle a Location.


Constructor Summary
LocatedVehicle(int vin, double lat, double lon)
          Create a new LocatedVehicle object with the given vehicle id number and located at the given location.
 
Method Summary
 double distanceTo(Locatable other)
          Calculate the distance to another Locatable object
 Location getLocation()
          Return a reference to a copy of the Location object describing our current position.
 void setLocation(double lat, double lon)
          Set the values of our current Location by copying them from the arguments provided.
 void setLocation(Location loc)
          Set the values of our current Location by copying them from the given Location object.
 
Methods inherited from class Vehicle
compareTo, equals, getVIN, hashCode, main, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocatedVehicle

public LocatedVehicle(int vin,
                      double lat,
                      double lon)
Create a new LocatedVehicle object with the given vehicle id number and located at the given location.

Parameters:
vin - the vehicle id number
lat - the latitude where this Vehicle is located. Must satisfy the constraints defined by the Location class.
lon - the longitude where this Vehicle is located. Must satisfy the constraints defined by the Location class.
Method Detail

getLocation

public Location getLocation()
Return a reference to a copy of the Location object describing our current position.

Specified by:
getLocation in interface Locatable
Returns:
a copy of the Location object for this object

setLocation

public void setLocation(Location loc)
Set the values of our current Location by copying them from the given Location object.

Specified by:
setLocation in interface Locatable
Parameters:
loc - the Location to copy from

setLocation

public void setLocation(double lat,
                        double lon)
Set the values of our current Location by copying them from the arguments provided. The arguments must satisfy the constraints imposed by the Location class.

Specified by:
setLocation in interface Locatable
Parameters:
lat - the new latitude value
lon - the new longitude value

distanceTo

public double distanceTo(Locatable other)
Calculate the distance to another Locatable object

Specified by:
distanceTo in interface Locatable
Parameters:
other - the other Location
Returns:
the distance in meters to the other object