ADDED isvalid() gettraveltime() getminimumtraveltime()

This commit is contained in:
Guillaume Vincent 2020-03-25 17:03:06 +01:00
parent 41a7ead4b5
commit cab5bb631d

View file

@ -34,6 +34,8 @@ public class Path {
*/
public static Path createFastestPathFromNodes(Graph graph, List<Node> nodes)
throws IllegalArgumentException {
List<Arc> arcs = new ArrayList<Arc>();
//TODO
return new Path(graph, arcs);
@ -201,8 +203,18 @@ public class Path {
* @deprecated Need to be implemented.
*/
public boolean isValid() {
// TODO:
return false;
//DONE:
if (isEmpty()) {return true;}
if (size()==1) {return true;}
if (size()>1) {
if (arcs.get(0).getOrigin()!=origin) {return false;}
for(int i=1; i<size()-1;i++)
{
if (arcs.get(i).getOrigin()!=arcs.get(i-1).getDestination()) {return false;}
}
return true;
}
return false;
}
/**
@ -234,8 +246,15 @@ public class Path {
* @deprecated Need to be implemented.
*/
public double getTravelTime(double speed) {
// TODO:
return 0;
// DONE:
float time = 0;
for (Arc arc : this.arcs) {
time += arc.getTravelTime(speed);
}
return time;
}
/**
@ -247,8 +266,12 @@ public class Path {
* @deprecated Need to be implemented.
*/
public double getMinimumTravelTime() {
// TODO:
return 0;
// DONE:
float time = 0;
for (Arc arc : this.arcs) {
time += arc.getTravelTime(arc.getRoadInformation().getMaximumSpeed());
}
return time;
}
}