ajout des fonctions isValid et tempsMin

This commit is contained in:
alejeune 2022-03-27 21:37:35 +02:00
parent 1f6999aefc
commit a8f7f4ed5a

View file

@ -198,12 +198,39 @@ public class Path {
* *
* @return true if the path is valid, false otherwise. * @return true if the path is valid, false otherwise.
* *
* @deprecated Need to be implemented.
*/ */
public boolean isValid() { public boolean isValid() {
// TODO: Arc old = null;
// it is empty
if (this.isEmpty()) {
return true;
}
// Origin is ok
if ((this.origin != null) && (this.arcs.size() == 0)) {
return true;
}
if (this.arcs.size() == 0) {
return false; return false;
} }
// destination of the first one is the origin of the second node
if (this.arcs.get(0).getOrigin() == this.origin) {
for (Arc a : this.arcs) {
if (this.arcs.get(0) == a) {
old = this.arcs.get(0);
}
else if (old.getDestination() == a.getOrigin()) {
old = a;
}
else {
return false;
}
}
return true;
}
else {
return false;
}
}
/** /**
* Compute the length of this path (in meters). * Compute the length of this path (in meters).
@ -213,7 +240,7 @@ public class Path {
*/ */
public float getLength() { public float getLength() {
float acc = 0; float acc = 0;
for (Arc l : arcs) { for (Arc l : this.arcs) {
acc += l.getLength(); acc += l.getLength();
} }
@ -240,11 +267,13 @@ public class Path {
* *
* @return Minimum travel time to travel this path (in seconds). * @return Minimum travel time to travel this path (in seconds).
* *
* @deprecated Need to be implemented.
*/ */
public double getMinimumTravelTime() { public double getMinimumTravelTime() {
// TODO: float acc = 0;
return 0; for (Arc l : this.arcs) {
acc += l.getMinimumTravelTime();
}
return acc;
} }
} }