Compare commits

..

2 commits

Author SHA1 Message Date
52df139bd8 Implemented valid and travel time methods 2020-03-20 14:56:52 +01:00
b070983a49 Implemented getLength 2020-03-20 14:44:43 +01:00
2 changed files with 27 additions and 14 deletions

View file

@ -201,20 +201,29 @@ 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;
}
/**
* Compute the length of this path (in meters).
*
* @return Total length of the path (in meters).
*
* @deprecated Need to be implemented.
*
*/
public float getLength() {
// TODO:
return 0;
float length = 0;
for (Arc a : this.arcs) {
length += a.getLength();
}
return length;
}
/**
@ -224,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;
}
/**
@ -237,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;
}
}

BIN
uml.dia

Binary file not shown.