From 95b68f3e31dcb543e508b04984c69a4c72cb15df Mon Sep 17 00:00:00 2001 From: Holt59 Date: Mon, 12 Mar 2018 20:43:32 +0100 Subject: [PATCH] Length -> Float. Fix issue with duplicated backward arcs. --- src/main/org/insa/graph/Arc.java | 2 +- src/main/org/insa/graph/ArcBackward.java | 7 +++---- src/main/org/insa/graph/ArcForward.java | 7 +++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/org/insa/graph/Arc.java b/src/main/org/insa/graph/Arc.java index 2f5b3d8..12806dd 100644 --- a/src/main/org/insa/graph/Arc.java +++ b/src/main/org/insa/graph/Arc.java @@ -31,7 +31,7 @@ public abstract class Arc { /** * @return Length of this arc, in meters. */ - public abstract double getLength(); + public abstract float getLength(); /** * Compute the time required to travel this arc if moving at the given speed. diff --git a/src/main/org/insa/graph/ArcBackward.java b/src/main/org/insa/graph/ArcBackward.java index 6ae21bd..4ea6cae 100644 --- a/src/main/org/insa/graph/ArcBackward.java +++ b/src/main/org/insa/graph/ArcBackward.java @@ -13,7 +13,7 @@ import java.util.List; class ArcBackward extends Arc { // Original arc - private final ArcForward originalArc; + private final Arc originalArc; /** * Create a new backward arc which corresponds to the reverse arc of the given @@ -21,9 +21,8 @@ class ArcBackward extends Arc { * * @param originalArc Original forwarc arc corresponding to this backward arc. */ - protected ArcBackward(ArcForward originalArc) { + protected ArcBackward(Arc originalArc) { this.originalArc = originalArc; - this.originalArc.getDestination().addSuccessor(this); } @Override @@ -37,7 +36,7 @@ class ArcBackward extends Arc { } @Override - public double getLength() { + public float getLength() { return this.originalArc.getLength(); } diff --git a/src/main/org/insa/graph/ArcForward.java b/src/main/org/insa/graph/ArcForward.java index 13ff2af..5bf947d 100644 --- a/src/main/org/insa/graph/ArcForward.java +++ b/src/main/org/insa/graph/ArcForward.java @@ -1,6 +1,5 @@ package org.insa.graph; -import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -21,7 +20,7 @@ class ArcForward extends Arc { private final RoadInformation info; // Segments. - private final ArrayList points; + private final List points; /** * Create a new ArcForward with the given attributes. @@ -33,7 +32,7 @@ class ArcForward extends Arc { * @param points Points representing this arc. */ protected ArcForward(Node origin, Node dest, float length, RoadInformation roadInformation, - ArrayList points) { + List points) { this.origin = origin; this.destination = dest; this.length = length; @@ -52,7 +51,7 @@ class ArcForward extends Arc { } @Override - public double getLength() { + public float getLength() { return length; }