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,11 +198,38 @@ public class Path {
*
* @return true if the path is valid, false otherwise.
*
* @deprecated Need to be implemented.
*/
public boolean isValid() {
// TODO:
return false;
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;
}
// 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;
}
}
/**
@ -213,7 +240,7 @@ public class Path {
*/
public float getLength() {
float acc = 0;
for (Arc l : arcs) {
for (Arc l : this.arcs) {
acc += l.getLength();
}
@ -240,11 +267,13 @@ public class Path {
*
* @return Minimum travel time to travel this path (in seconds).
*
* @deprecated Need to be implemented.
*/
public double getMinimumTravelTime() {
// TODO:
return 0;
float acc = 0;
for (Arc l : this.arcs) {
acc += l.getMinimumTravelTime();
}
return acc;
}
}