Merge branch 'master' of https://eng-git.canterbury.ac.nz/seng302-2017/team-7
This commit is contained in:
@@ -11,6 +11,7 @@ import seng302.Controllers.RaceController;
|
||||
import seng302.GPSCoordinate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Parent class for races
|
||||
@@ -171,6 +172,11 @@ public abstract class Race implements Runnable {
|
||||
Platform.runLater(() -> {controller.setFrames("FPS: " + fps);});
|
||||
}
|
||||
|
||||
private boolean doNotFinish() {
|
||||
Random rand = new Random();
|
||||
return rand.nextInt(100) < 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Race Simulation, playing the race start to finish with the timescale.
|
||||
* This prints the boats participating, the order that the events occur in time order, and the respective information of the events.
|
||||
@@ -243,6 +249,10 @@ public abstract class Race implements Runnable {
|
||||
boatsFinished++;
|
||||
boat.setFinished(true);
|
||||
boat.setTimeFinished(timeElapsed);
|
||||
} else if(doNotFinish()) {
|
||||
boatsFinished++;
|
||||
boat.setFinished(true);
|
||||
boat.setCurrentLeg(new Leg("DNF",-1));
|
||||
} else {
|
||||
boat.setDistanceTravelledInLeg(boat.getDistanceTravelledInLeg() - boat.getCurrentLeg().getDistance());
|
||||
Leg nextLeg = legs.get(boat.getCurrentLeg().getLegNumber() + 1);
|
||||
|
||||
Reference in New Issue
Block a user