-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeoCoord.java
34 lines (28 loc) · 890 Bytes
/
GeoCoord.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
public class GeoCoord implements Comparable<GeoCoord>
{
double latitude;
double longitude;
String sLatitude;
String sLongitude;
GeoCoord(String latitude, String longitude)
{
this.latitude = Double.parseDouble(latitude);
this.longitude = Double.parseDouble(longitude);
sLatitude = latitude;
sLongitude = longitude;
}
public boolean equals(Object o){
GeoCoord c = (GeoCoord) o;
return (this.latitude == c.latitude) && (this.longitude == c.longitude);
}
public int compareTo(GeoCoord c){
if(this.latitude < c.latitude) return -1;
if(this.latitude > c.latitude) return +1;
if(this.longitude < c.longitude) return -1;
if(this.longitude > c.longitude) return +1;
return 0;
}
public String toString(){
return sLatitude + ", " + sLongitude;
}
}