|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--hw6.Vehicle | +--hw6.LocatedVehicle
This class implements the ability to give a Vehicle a Location.
Field Summary |
Fields inherited from class hw6.Vehicle |
vin |
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 | |
java.lang.Object |
clone()
Create a copy of this LocatedVehicle object. |
double |
distanceTo(hw6.Locatable other)
Calculate the distance to another Locatable object |
hw6.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(hw6.Location loc)
Set the values of our current Location by copying them from the given Location object. |
java.lang.String |
toString()
Provide a String representation of this LocatedVehicle. |
Methods inherited from class hw6.Vehicle |
compareTo, equals, getVIN, hashCode, main |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public LocatedVehicle(int vin, double lat, double lon)
vin
- the vehicle id numberlat
- 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 |
public hw6.Location getLocation()
getLocation
in interface Locatable
public void setLocation(hw6.Location loc)
setLocation
in interface Locatable
loc
- the Location to copy frompublic void setLocation(double lat, double lon)
setLocation
in interface Locatable
lat
- the new latitude valuelon
- the new longitude valuepublic double distanceTo(hw6.Locatable other)
distanceTo
in interface Locatable
other
- the other Location
public java.lang.String toString()
toString
in class Vehicle
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class Vehicle
java.lang.CloneNotSupportedException
- but this should never happen
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |