diff --git a/src/main/java/seng302/Constants.java b/src/main/java/seng302/Constants.java index 125e5444..0db52afb 100644 --- a/src/main/java/seng302/Constants.java +++ b/src/main/java/seng302/Constants.java @@ -1,5 +1,7 @@ package seng302; +import javafx.scene.paint.Color; +import seng302.Model.BoatInRace; import seng302.Model.Leg; /** @@ -22,5 +24,13 @@ public class Constants { public static final GPSCoordinate finishLineMarker1 = new GPSCoordinate(32.317379, -64.839291); public static final GPSCoordinate finishLineMarker2 = new GPSCoordinate(32.317257, -64.836260); + public static final BoatInRace[] OFFICIAL_AC35_COMPETITORS = new BoatInRace[] + {new BoatInRace("Oracle Team USA", 200.0, Color.BLUEVIOLET), + new BoatInRace("Land Rover BAR", 180.0, Color.BLACK), + new BoatInRace("SoftBank Team Japan", 190.0, Color.RED), + new BoatInRace("Groupama Team France", 210.0, Color.ORANGE), + new BoatInRace("Artemis Racing", 220.0, Color.DARKOLIVEGREEN), + new BoatInRace("Emirates Team New Zealand", 310, Color.LIMEGREEN)}; + //public static final Leg bermudaCourseStartToMark1 = new Leg(0, , new ) } diff --git a/src/main/java/seng302/Controllers/RaceController.java b/src/main/java/seng302/Controllers/RaceController.java index 0b8402f0..c3b74ad1 100644 --- a/src/main/java/seng302/Controllers/RaceController.java +++ b/src/main/java/seng302/Controllers/RaceController.java @@ -110,18 +110,17 @@ public class RaceController extends Controller{ private BoatInRace[] generateAC35Competitors() { - BoatInRace boat1 = new BoatInRace("NZ", 500); - boat1.setColour(Color.DARKVIOLET); - boat1.setCurrentPosition(new GPSCoordinate(0, 0)); - - BoatInRace boat2 = new BoatInRace("TEST", 400); - boat2.setColour(Color.DARKRED); - boat2.setCurrentPosition(new GPSCoordinate(0, 0)); - - BoatInRace boat3 = new BoatInRace("TEST2", 350); - boat3.setColour(Color.FUCHSIA); - boat3.setCurrentPosition(new GPSCoordinate(0, 0)); - return new BoatInRace[] {boat1, boat2, boat3}; + BoatInRace[] boats = new BoatInRace[6]; + + + int i = 0; + for (BoatInRace boat : Constants.OFFICIAL_AC35_COMPETITORS) { + boat.setCurrentPosition(Constants.startLineMarker1); + boats[i] = boat; + i++; + } + + return boats; } diff --git a/src/main/java/seng302/Model/BoatInRace.java b/src/main/java/seng302/Model/BoatInRace.java index 200a2fff..6a7b9287 100644 --- a/src/main/java/seng302/Model/BoatInRace.java +++ b/src/main/java/seng302/Model/BoatInRace.java @@ -19,6 +19,17 @@ public class BoatInRace extends Boat { private Color colour; private boolean finished = false; + /** + * Constructor method. + * @param name Name of the boat. + * @param velocity Speed that the boat travels. + * @param colour Colour the boat will be displayed as on the map + */ + public BoatInRace(String name, double velocity, Color colour) { + super(name, velocity); + setColour(colour); + } + /** * * @return Returns the current position of the boat in a GPSCoordinate Class. @@ -61,15 +72,6 @@ public class BoatInRace extends Boat { this.timeFinished = timeFinished; } - /** - * Constructor method. - * @param name Name of the boat. - * @param velocity Speed that the boat travels. - */ - public BoatInRace(String name, double velocity) { - super(name, velocity); - } - /** * Gets the current leg that the boat is on. * @return returns the leg the boat is on in a Leg class diff --git a/src/main/java/seng302/Model/Race.java b/src/main/java/seng302/Model/Race.java index 7c8e0c7f..3fd39672 100644 --- a/src/main/java/seng302/Model/Race.java +++ b/src/main/java/seng302/Model/Race.java @@ -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()); }