# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
This commit is contained in:
Fan-Wu Yang
2017-03-17 13:13:23 +13:00
+10
View File
@@ -63,10 +63,20 @@ public abstract class Race implements Runnable {
long timeLoopStarted; long timeLoopStarted;
long timeLoopEnded; long timeLoopEnded;
long minutes;
long currentTimeInSeconds;
long remainingSeconds;
while (finishingBoats.size() < startingBoats.length) { while (finishingBoats.size() < startingBoats.length) {
timeLoopStarted = System.currentTimeMillis(); timeLoopStarted = System.currentTimeMillis();
totalTimeElapsed = System.currentTimeMillis() - timeRaceStarted; totalTimeElapsed = System.currentTimeMillis() - timeRaceStarted;
long currentTime = System.currentTimeMillis() - timeRaceStarted;
currentTimeInSeconds = currentTime / 1000;
minutes = currentTimeInSeconds / 60;
remainingSeconds = currentTimeInSeconds % 60;
System.out.println(minutes + ":" + remainingSeconds);
for (BoatInRace boat : startingBoats) { for (BoatInRace boat : startingBoats) {
updatePosition(boat, SLEEP_TIME); updatePosition(boat, SLEEP_TIME);
checkPosition(boat, totalTimeElapsed); checkPosition(boat, totalTimeElapsed);