-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollision.java
More file actions
61 lines (49 loc) · 1.22 KB
/
Collision.java
File metadata and controls
61 lines (49 loc) · 1.22 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
package cas2xb3.greenlight;
public class Collision implements Comparable {
private int index;
private double latitude;
private double longitude;
private int severity;
private int weather;
private int paved;
public Collision(int index, double lat, double lng, int CSEV, int weather, int paved) {
this.index = index;
latitude = lat;
longitude = lng;
severity = CSEV;
this.weather = weather;
this.paved = paved;
}
public int getIndex() {
return index;
}
public double getLat() {
return latitude;
}
public double getLng() {
return longitude;
}
public int getSeverity() {
return severity;
}
public int getWeather() {
return weather;
}
public int getPaved() {
return paved;
}
public double getEquation() {
return (1.0 / (2 * getSeverity()) + 1 / (5 * getWeather())) * (0.9 + (getPaved() / 10));
}
public double distance(Collision that) {
return Math.sqrt(Math.pow(this.getLat() - that.getLat(), 2) + Math.pow(this.getLng() - that.getLng(), 2));
}
@Override
public int compareTo(Object o) {
Collision c = (Collision) o;
if (this.latitude == c.latitude)
return 0;
else
return this.latitude > c.latitude ? 1 : -1;
}
}