Added a number of race tests.

- Still unable to get animation timer tests working. May be necessary to make handle() hold nothing but a method call

#story[881]
This commit is contained in:
Erika Savell
2017-05-11 15:43:12 +12:00
parent 0bb18c7957
commit 11f6dee301
2 changed files with 226 additions and 147 deletions
+4 -4
View File
@@ -208,8 +208,8 @@ public class Race implements Runnable {
//distanceTravelled = velocity (nm p hr) * time taken to update loop
double distanceTravelled = (boat.getScaledVelocity() * millisecondsElapsed) / 3600000;
double totalDistanceTravelled = distanceTravelled + boat.getDistanceTravelledInLeg();
System.out.println(totalDistanceTravelled);
boolean finish = boat.getCurrentLeg().getName().equals("Finish");
if (!finish) {
@@ -225,11 +225,14 @@ public class Race implements Runnable {
protected void checkPosition(Boat boat, long timeElapsed) {
if (boat.getDistanceTravelledInLeg() > boat.getCurrentLeg().getDistance()) {
//boat has passed onto new leg
if (boat.getCurrentLeg().getName().equals("Finish")) {
//boat has finished
boatsFinished++;
boat.setTimeFinished(timeElapsed);
boat.setTimeFinished(timeElapsed);
boat.setVelocity(0);
boat.setScaledVelocity(0);
} else if (doNotFinish()) {
boatsFinished++;
boat.setTimeFinished(timeElapsed);
@@ -241,10 +244,7 @@ public class Race implements Runnable {
boat.setDistanceTravelledInLeg(boat.getDistanceTravelledInLeg() - boat.getCurrentLeg().getDistance());
//Move boat on to next leg
Leg nextLeg = legs.get(boat.getCurrentLeg().getLegNumber() + 1);
boat.setCurrentLeg(nextLeg);
//Add overshoot distance into the distance travelled for the next leg
boat.setDistanceTravelledInLeg(boat.getDistanceTravelledInLeg());
}
}
}