Implemented valid and travel time methods
This commit is contained in:
parent
b070983a49
commit
52df139bd8
1 changed files with 21 additions and 10 deletions
|
@ -201,8 +201,15 @@ public class Path {
|
|||
* @deprecated Need to be implemented.
|
||||
*/
|
||||
public boolean isValid() {
|
||||
// TODO:
|
||||
return false;
|
||||
boolean valid = isEmpty() || (this.arcs.size() == 0 && this.origin != null);
|
||||
if (!valid) {
|
||||
valid = this.arcs.get(0).getOrigin().equals(this.origin);
|
||||
for (int i = 1; i < 3; i++) {
|
||||
if (this.arcs.size() > i)
|
||||
valid = valid && (this.arcs.get(i).getOrigin().equals(this.arcs.get(i-1).getDestination()));
|
||||
}
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,12 +233,14 @@ 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;
|
||||
float time = 0;
|
||||
for (Arc a : this.arcs) {
|
||||
time += a.getTravelTime(speed);
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -239,12 +248,14 @@ public class Path {
|
|||
* on every arc.
|
||||
*
|
||||
* @return Minimum travel time to travel this path (in seconds).
|
||||
*
|
||||
* @deprecated Need to be implemented.
|
||||
*
|
||||
*/
|
||||
public double getMinimumTravelTime() {
|
||||
// TODO:
|
||||
return 0;
|
||||
float time = 0;
|
||||
for (Arc a : this.arcs) {
|
||||
time += a.getMinimumTravelTime();
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue