-
Notifications
You must be signed in to change notification settings - Fork 0
/
StreetSegment.java
49 lines (39 loc) · 1.45 KB
/
StreetSegment.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.List;
import java.util.ArrayList;
class Address
{
String attraction;
GeoCoord location;
public Address(String attraction, GeoCoord location){
this.attraction = attraction;
this.location = location;
}
}
public class StreetSegment implements Comparable<StreetSegment>
{
String streetName;
GeoSegment segment;
List<Address> attractionsOnThisSegment;
StreetSegment(String streetName, GeoSegment segment){
this.streetName = streetName;
this.segment = segment;
attractionsOnThisSegment = new ArrayList<Address>();
}
public boolean equals(Object streetSeg){
StreetSegment s = (StreetSegment) streetSeg;
return (segment.start.equals(s.segment.start)) && (segment.end.equals(s.segment.end));
}
public int compareTo(StreetSegment s){
if(segment.start == s.segment.start)
return segment.end.compareTo(s.segment.end);
return segment.start.compareTo(s.segment.start);
}
public String toString(){
System.out.println("street name:" + streetName);
System.out.println("geoSegment:" + "\n" + segment.toString());
System.out.println("number of attractions:" + attractionsOnThisSegment.size());
for(Address a : attractionsOnThisSegment)
System.out.println("attraction:" + a.attraction + ", location:" + a.location.toString());
return "";
}
}