You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.8 KiB
73 lines
1.8 KiB
package seng302;
|
|
|
|
/**
|
|
* GPS Coordinate for the world map.
|
|
* Created by esa46 on 15/03/17.
|
|
*/
|
|
public class GPSCoordinate {
|
|
|
|
private double latitude;
|
|
private double longitude;
|
|
|
|
/**
|
|
* Constructor Method
|
|
*
|
|
* @param latitude latitude the coordinate is located at.
|
|
* @param longitude Longitude that the coordinate is located at.
|
|
*/
|
|
public GPSCoordinate(double latitude, double longitude) {
|
|
this.latitude = latitude;
|
|
this.longitude = longitude;
|
|
}
|
|
|
|
/**
|
|
* Gets the Latitude that the Coordinate is at.
|
|
*
|
|
* @return Returns the latitude of the Coordinate.
|
|
*/
|
|
public double getLatitude() {
|
|
return latitude;
|
|
}
|
|
|
|
/**
|
|
* Gets the Longitude that the Coordinate is at.
|
|
*
|
|
* @return Returns the longitude of the Coordinate.
|
|
*/
|
|
public double getLongitude() {
|
|
return longitude;
|
|
}
|
|
|
|
/**
|
|
* To String method of the Coordinate in the form Latitude: $f, Longitude: $f.
|
|
*
|
|
* @return A String representation of the GPSCoordinate Class.
|
|
*/
|
|
public String toString() {
|
|
return String.format("Latitude: %f, Longitude: %f", latitude, longitude);
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) return true;
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
|
|
GPSCoordinate that = (GPSCoordinate) o;
|
|
|
|
if (Math.abs(this.latitude - latitude) > 1e-6) return false;
|
|
return (Math.abs(this.longitude - longitude) < 1e-6);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
int result;
|
|
long temp;
|
|
temp = Double.doubleToLongBits(latitude);
|
|
result = (int) (temp ^ (temp >>> 32));
|
|
temp = Double.doubleToLongBits(longitude);
|
|
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
|
return result;
|
|
}
|
|
}
|
|
|