|
|
|
|
@ -21,7 +21,7 @@ public abstract class Race implements Runnable {
|
|
|
|
|
protected int boatsFinished = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int SLEEP_TIME = 1000; //time in milliseconds to pause in a paced loop
|
|
|
|
|
private int SLEEP_TIME = 100; //time in milliseconds to pause in a paced loop
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Initailiser for Race
|
|
|
|
|
@ -62,7 +62,8 @@ public abstract class Race implements Runnable {
|
|
|
|
|
System.out.println("====================");
|
|
|
|
|
for (int i = 0; i < startingBoats.size(); i++) {
|
|
|
|
|
if (startingBoats.get(i) != null) {
|
|
|
|
|
System.out.println(i + 1 + ". " + startingBoats.get(i).getName() + ", Speed: " + Math.round(startingBoats.get(i).getVelocity() * 1.94384) + "kn");
|
|
|
|
|
System.out.println(i + 1 + ". " + startingBoats.get(i).getName() + ", Speed: "
|
|
|
|
|
+ Math.round(startingBoats.get(i).getVelocity() * 1.94384) + "kn");
|
|
|
|
|
startingBoats.get(i).setCurrentLeg(legs.get(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -119,7 +120,7 @@ public abstract class Race implements Runnable {
|
|
|
|
|
*/
|
|
|
|
|
protected void checkPosition(BoatInRace boat, long timeElapsed) {
|
|
|
|
|
if (boat.getDistanceTravelledInLeg() > boat.getCurrentLeg().getDistance()){
|
|
|
|
|
//updateController(); removed as we do not update the table every time anymore.
|
|
|
|
|
// updateController();
|
|
|
|
|
//boat has passed onto new leg
|
|
|
|
|
if (boat.getCurrentLeg().getName().equals("Finish")) {
|
|
|
|
|
//boat has finished
|
|
|
|
|
@ -128,6 +129,7 @@ public abstract class Race implements Runnable {
|
|
|
|
|
} else {
|
|
|
|
|
boat.setDistanceTravelledInLeg(boat.getDistanceTravelledInLeg() - boat.getCurrentLeg().getDistance());
|
|
|
|
|
Leg nextLeg = legs.get(boat.getCurrentLeg().getLegNumber() + 1);
|
|
|
|
|
|
|
|
|
|
boat.setCurrentLeg(nextLeg);
|
|
|
|
|
boat.setDistanceTravelledInLeg(boat.getDistanceTravelledInLeg());
|
|
|
|
|
}
|
|
|
|
|
|