|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--hw7.Location
This class is a way for objects to keep track of where they are in a 2-dimensional latitude & longitude based coordinate system.
Constructor Summary | |
Location(double lat,
double lon)
Create a new Location object, given a latitude and longitude. |
Method Summary | |
java.lang.Object |
clone()
Create a copy of this Location object. |
double |
distance(Location other)
Calculate the distance between two locations. |
double |
getLatitude()
Get the latitude value for this Location |
double |
getLongitude()
Get the longitude value for this Location |
static void |
main(java.lang.String[] arg)
Test harness for this class. |
java.lang.String |
toString()
Provide a String representation of our location. |
void |
update(double lat,
double lon)
Update the current location based on the values provided. |
void |
update(Location loc)
Update the current location based on the Location object provided. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Location(double lat, double lon)
lat
- the latitude. This value must be from -90. to +90. and
this constructor throws a RuntimeException if that is not true.lon
- the longitude. This value can range from -180. to +180.
and this constructor throws a RuntimeException if that is not true.Method Detail |
public double distance(Location other)
other
- the other Locationpublic void update(Location loc)
loc
- the Location from which to copy the lat and lon values.public void update(double lat, double lon)
lat
- the latitude. This value must be from -90. to +90. and
this method throws a RuntimeException if that is not true.lon
- the longitude. This value can range from -180. to +180.
and this method throws a RuntimeException if that is not true.public double getLatitude()
public double getLongitude()
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] arg)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |