ADDED getLength()

This commit is contained in:
Guillaume Vincent 2020-03-20 18:23:56 +01:00
parent 61e29e6787
commit 41a7ead4b5

View file

@ -35,7 +35,7 @@ public class Path {
public static Path createFastestPathFromNodes(Graph graph, List<Node> nodes) public static Path createFastestPathFromNodes(Graph graph, List<Node> nodes)
throws IllegalArgumentException { throws IllegalArgumentException {
List<Arc> arcs = new ArrayList<Arc>(); List<Arc> arcs = new ArrayList<Arc>();
// TODO: //TODO
return new Path(graph, arcs); return new Path(graph, arcs);
} }
@ -213,8 +213,14 @@ public class Path {
* @deprecated Need to be implemented. * @deprecated Need to be implemented.
*/ */
public float getLength() { public float getLength() {
// TODO: // DONE:
return 0;
float length = 0;
for (Arc arc : this.arcs) {
length += arc.getLength();
}
return length;
} }
/** /**