modif : isValid, getLength, getTravelTime, getMinimumTravelTime

This commit is contained in:
Norgeux Lea 2023-03-22 10:34:25 +01:00
parent 1ebdc88d8c
commit 9a8c602289

View file

@ -201,8 +201,30 @@ public class Path {
* @deprecated Need to be implemented. * @deprecated Need to be implemented.
*/ */
public boolean isValid() { public boolean isValid() {
// TODO:
return false;
if (this.isEmpty() == true) {
return true ;
}
if (this.size() == 1) {
return true ;
}
int i = 0 ;
if (!this.getArcs().get(i).getOrigin().equals(this.origin)) {
return false ;
}
for (i=1;i<this.getArcs().size();i++) {
if (!this.getArcs().get(i-1).getDestination().equals(this.getArcs().get(i).getOrigin())) {
return false ;
}
}
return true ;
} }
/** /**
@ -210,11 +232,14 @@ public class Path {
* *
* @return Total length of the path (in meters). * @return Total length of the path (in meters).
* *
* @deprecated Need to be implemented. *
*/ */
public float getLength() { public float getLength() {
// TODO: float result = 0.0f ;
return 0; for (Arc a : this.getArcs()) {
result += a.getLength() ;
}
return result;
} }
/** /**
@ -225,11 +250,10 @@ public class Path {
* @return Time (in seconds) required to travel this path at the given speed (in * @return Time (in seconds) required to travel this path at the given speed (in
* kilometers-per-hour). * kilometers-per-hour).
* *
* @deprecated Need to be implemented. *
*/ */
public double getTravelTime(double speed) { public double getTravelTime(double speed) {
// TODO: return (this.getLength()/speed)*3.6f;
return 0;
} }
/** /**
@ -238,11 +262,14 @@ 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: double result = 0.0 ;
return 0; for (Arc a : this.getArcs()) {
result += a.getMinimumTravelTime() ;
}
return result ;
} }
} }