modif : isValid, getLength, getTravelTime, getMinimumTravelTime
This commit is contained in:
parent
1ebdc88d8c
commit
9a8c602289
1 changed files with 38 additions and 11 deletions
|
@ -201,8 +201,30 @@ public class Path {
|
|||
* @deprecated Need to be implemented.
|
||||
*/
|
||||
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).
|
||||
*
|
||||
* @deprecated Need to be implemented.
|
||||
*
|
||||
*/
|
||||
public float getLength() {
|
||||
// TODO:
|
||||
return 0;
|
||||
float result = 0.0f ;
|
||||
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
|
||||
* kilometers-per-hour).
|
||||
*
|
||||
* @deprecated Need to be implemented.
|
||||
*
|
||||
*/
|
||||
public double getTravelTime(double speed) {
|
||||
// TODO:
|
||||
return 0;
|
||||
return (this.getLength()/speed)*3.6f;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -238,11 +262,14 @@ public class Path {
|
|||
*
|
||||
* @return Minimum travel time to travel this path (in seconds).
|
||||
*
|
||||
* @deprecated Need to be implemented.
|
||||
*
|
||||
*/
|
||||
public double getMinimumTravelTime() {
|
||||
// TODO:
|
||||
return 0;
|
||||
double result = 0.0 ;
|
||||
for (Arc a : this.getArcs()) {
|
||||
result += a.getMinimumTravelTime() ;
|
||||
}
|
||||
return result ;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue