Browse Source

Fix Arc and add @deprecated javadoc for students to implement.

Holt59 6 years ago
parent
commit
e0268c80af

+ 23
- 7
src/main/org/insa/graph/Arc.java View File

16
  * @see ArcBackward
16
  * @see ArcBackward
17
  *
17
  *
18
  */
18
  */
19
-public interface Arc {
19
+public abstract class Arc {
20
 
20
 
21
     /**
21
     /**
22
      * @return Origin node of this arc.
22
      * @return Origin node of this arc.
23
      */
23
      */
24
-    public Node getOrigin();
24
+    public abstract Node getOrigin();
25
 
25
 
26
     /**
26
     /**
27
      * @return Destination node of this arc.
27
      * @return Destination node of this arc.
28
      */
28
      */
29
-    public Node getDestination();
29
+    public abstract Node getDestination();
30
 
30
 
31
     /**
31
     /**
32
      * @return Length of this arc, in meters.
32
      * @return Length of this arc, in meters.
33
      */
33
      */
34
-    public float getLength();
34
+    public abstract double getLength();
35
+
36
+    /**
37
+     * Compute the time required to travel this arc if moving at the given speed.
38
+     * 
39
+     * @param speed Speed to compute the travel time.
40
+     * 
41
+     * @return Time (in seconds) required to travel this arc at the given speed (in
42
+     *         kilometers-per-hour).
43
+     */
44
+    public double getTravelTime(double speed) {
45
+        return getLength() * 3600.0 / (speed * 1000.0);
46
+    }
35
 
47
 
36
     /**
48
     /**
37
      * @return Minimum time required to travel this arc, in seconds.
49
      * @return Minimum time required to travel this arc, in seconds.
50
+     * 
51
+     * @see Arc#getTravelTime(double)
38
      */
52
      */
39
-    public double getMinimumTravelTime();
53
+    public double getMinimumTravelTime() {
54
+        return getTravelTime(getRoadInformation().getMaximumSpeed());
55
+    }
40
 
56
 
41
     /**
57
     /**
42
      * @return Road information for this arc.
58
      * @return Road information for this arc.
43
      */
59
      */
44
-    public RoadInformation getRoadInformation();
60
+    public abstract RoadInformation getRoadInformation();
45
 
61
 
46
     /**
62
     /**
47
      * @return Points representing segments of this arc.
63
      * @return Points representing segments of this arc.
48
      */
64
      */
49
-    public List<Point> getPoints();
65
+    public abstract List<Point> getPoints();
50
 }
66
 }

+ 2
- 7
src/main/org/insa/graph/ArcBackward.java View File

10
  * the original arc.
10
  * the original arc.
11
  *
11
  *
12
  */
12
  */
13
-class ArcBackward implements Arc {
13
+class ArcBackward extends Arc {
14
 
14
 
15
     // Original arc
15
     // Original arc
16
     private final ArcForward originalArc;
16
     private final ArcForward originalArc;
37
     }
37
     }
38
 
38
 
39
     @Override
39
     @Override
40
-    public float getLength() {
40
+    public double getLength() {
41
         return this.originalArc.getLength();
41
         return this.originalArc.getLength();
42
     }
42
     }
43
 
43
 
44
     @Override
44
     @Override
45
-    public double getMinimumTravelTime() {
46
-        return this.originalArc.getMinimumTravelTime();
47
-    }
48
-
49
-    @Override
50
     public RoadInformation getRoadInformation() {
45
     public RoadInformation getRoadInformation() {
51
         return this.originalArc.getRoadInformation();
46
         return this.originalArc.getRoadInformation();
52
     }
47
     }

+ 2
- 7
src/main/org/insa/graph/ArcForward.java View File

9
  * arc implementation that stores data relative to the arc.
9
  * arc implementation that stores data relative to the arc.
10
  *
10
  *
11
  */
11
  */
12
-class ArcForward implements Arc {
12
+class ArcForward extends Arc {
13
 
13
 
14
     // Destination node.
14
     // Destination node.
15
     private final Node origin, destination;
15
     private final Node origin, destination;
52
     }
52
     }
53
 
53
 
54
     @Override
54
     @Override
55
-    public float getLength() {
55
+    public double getLength() {
56
         return length;
56
         return length;
57
     }
57
     }
58
 
58
 
59
     @Override
59
     @Override
60
-    public double getMinimumTravelTime() {
61
-        return getLength() * 3600.0 / (info.getMaximumSpeed() * 1000.0);
62
-    }
63
-
64
-    @Override
65
     public RoadInformation getRoadInformation() {
60
     public RoadInformation getRoadInformation() {
66
         return info;
61
         return info;
67
     }
62
     }

Loading…
Cancel
Save