From 8bb2558b7e51e9c3d83e616d8796addf3f662419 Mon Sep 17 00:00:00 2001 From: David Wu Date: Fri, 17 Mar 2017 12:06:35 +1300 Subject: [PATCH] Timer is now in race loop -Timer is currently printing out -Later will implement so that it is displayed on gui #story [16] --- src/main/java/seng302/Controllers/RaceController.java | 5 ++--- src/main/java/seng302/Model/Race.java | 10 ++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/seng302/Controllers/RaceController.java b/src/main/java/seng302/Controllers/RaceController.java index eeea8f78..f8969044 100644 --- a/src/main/java/seng302/Controllers/RaceController.java +++ b/src/main/java/seng302/Controllers/RaceController.java @@ -99,7 +99,7 @@ public class RaceController extends Controller{ BoatInRace boat = new BoatInRace("NZ", 10000); BoatInRace[] boats = new BoatInRace[] {boat}; - Leg leg1 = new Leg("first leg", 1, new GPSCoordinate(0, 0), new GPSCoordinate(1, 1), 0); + Leg leg1 = new Leg("first leg", 80, new GPSCoordinate(0, 0), new GPSCoordinate(200, 280), 0); Leg[] legs = new Leg[] {leg1}; ConstantVelocityRace race = new ConstantVelocityRace(boats, legs, this); @@ -135,8 +135,7 @@ public class RaceController extends Controller{ displayLine(startline1, startline2, Color.GREEN); //display wind direction arrow - specify origin point and angle - displayPoint(this.map.convertGPS(32.293771, -64.855242), Color.BLACK); - displayArrow(new GraphCoordinate(500, 20), 100); + displayArrow(new GraphCoordinate(500, 20), 0); diff --git a/src/main/java/seng302/Model/Race.java b/src/main/java/seng302/Model/Race.java index 8d8342a3..7fdbd6ad 100644 --- a/src/main/java/seng302/Model/Race.java +++ b/src/main/java/seng302/Model/Race.java @@ -63,10 +63,20 @@ public abstract class Race implements Runnable { long timeLoopStarted; long timeLoopEnded; + long minutes; + long currentTimeInSeconds; + long remainingSeconds; + while (finishingBoats.size() < startingBoats.length) { timeLoopStarted = System.currentTimeMillis(); 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) { updatePosition(boat, SLEEP_TIME); checkPosition(boat, totalTimeElapsed);