-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIntersection.java
62 lines (50 loc) · 1.93 KB
/
Intersection.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
50
51
52
53
54
55
56
57
58
59
60
61
62
public class Intersection {
Runway baseRunway;
Runway intersectingRunway;
int baseDistance;
int intersectingDistance;
public Intersection(Runway baseRun, Runway intersectingRunway, int baseDistance, int intersectingDistance) {
this.baseRunway = baseRun;
this.intersectingRunway = intersectingRunway;
this.baseDistance = baseDistance;
this.intersectingDistance = intersectingDistance;
}
public Runway getOtherRunway(Runway run) {
if (run.equals(baseRunway)) return intersectingRunway;
else if (run.equals(intersectingRunway)) return baseRunway;
else throw new IllegalArgumentException("Passed runway is not involved in this intersection!");
}
public boolean isInvolved(Runway run) {
if (run.equals(baseRunway) || run.equals(intersectingRunway)) return true;
else return false;
}
public Runway getBaseRunway() {
return baseRunway;
}
public int getRunwayDistance(Runway run) {
if (run.equals(this.getBaseRunway())) return getBaseDistance();
else if (run.equals(this.getIntersectingRunway())) return getIntersectingDistance();
else throw new IllegalArgumentException("Runway not involved in this intersection!");
}
public void setBaseRunway(Runway baseRunway) {
this.baseRunway = baseRunway;
}
public Runway getIntersectingRunway() {
return intersectingRunway;
}
public void setIntersectingRunway(Runway intersectingRunway) {
this.intersectingRunway = intersectingRunway;
}
public int getBaseDistance() {
return baseDistance;
}
public void setBaseDistance(int baseDistance) {
this.baseDistance = baseDistance;
}
public int getIntersectingDistance() {
return intersectingDistance;
}
public void setIntersectingDistance(int intersectingDistance) {
this.intersectingDistance = intersectingDistance;
}
}