Loaded official AC35 competitors

- Competitors pulled from americascup.com
- Added to a list of boats in Constants class, and this list is read by RaceController

#story[9] #implement
This commit is contained in:
Erika Savell
2017-03-20 15:47:09 +13:00
parent d0d4316bac
commit 66445a91a1
4 changed files with 35 additions and 22 deletions
+10
View File
@@ -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 )
}
@@ -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[] boats = new BoatInRace[6];
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};
int i = 0;
for (BoatInRace boat : Constants.OFFICIAL_AC35_COMPETITORS) {
boat.setCurrentPosition(Constants.startLineMarker1);
boats[i] = boat;
i++;
}
return boats;
}
+11 -9
View File
@@ -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
+5 -3
View File
@@ -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());
}