From 1de89b46d533535a959a95c1a82c04ed06ee2ebb Mon Sep 17 00:00:00 2001 From: georgia Date: Wed, 22 Mar 2023 10:50:20 +0100 Subject: [PATCH] changes --- .../main/java/org/insa/graphs/model/Path.java | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java b/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java index 6ebdb73..df5ec32 100644 --- a/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java +++ b/be-graphes-model/src/main/java/org/insa/graphs/model/Path.java @@ -202,7 +202,24 @@ public class Path { */ public boolean isValid() { // TODO: - return false; + boolean res=true; + //it is empty + if (this.size()!=0 && !this.arcs.isEmpty()){ + //it contains a single node without arcs + Node deb=origin; + for (Arc ligne : arcs){ + if (ligne.getOrigin().equals(deb)) { + deb=ligne.getDestination(); + } + else { + res=false; + } + } + + } + //the first arc has for origin the origin of the path and, for two consecutive arcs, the destination of the first one is the origin of the second one. + + return res; } /** @@ -214,7 +231,11 @@ public class Path { */ public float getLength() { // TODO: - return 0; + float res=0; + for (Arc ligne : arcs) { + res+=ligne.getLength(); + } + return res; } /** @@ -242,7 +263,12 @@ public class Path { */ public double getMinimumTravelTime() { // TODO: - return 0; + double min=0.0; + for (Arc ligne : arcs ){ + min+=ligne.getMinimumTravelTime(); + } + + return min; } }