added getLength()

This commit is contained in:
Lacroix Raphael 2022-03-25 17:17:22 +01:00
parent ca806aafff
commit 1f6999aefc

View file

@ -210,11 +210,14 @@ public class Path {
*
* @return Total length of the path (in meters).
*
* @deprecated Need to be implemented.
*/
public float getLength() {
// TODO:
return 0;
float acc = 0;
for (Arc l : arcs) {
acc += l.getLength();
}
return acc;
}
/**
@ -225,10 +228,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) {
return (this.getLength()/speed);
double speed2 = speed * 1000/3600;
return (this.getLength()/speed2);
}
/**