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
main
Erika Savell 9 years ago
parent d0d4316bac
commit 66445a91a1

@ -1,5 +1,7 @@
package seng302; package seng302;
import javafx.scene.paint.Color;
import seng302.Model.BoatInRace;
import seng302.Model.Leg; 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 finishLineMarker1 = new GPSCoordinate(32.317379, -64.839291);
public static final GPSCoordinate finishLineMarker2 = new GPSCoordinate(32.317257, -64.836260); 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 ) //public static final Leg bermudaCourseStartToMark1 = new Leg(0, , new )
} }

@ -110,18 +110,17 @@ public class RaceController extends Controller{
private BoatInRace[] generateAC35Competitors() { private BoatInRace[] generateAC35Competitors() {
BoatInRace boat1 = new BoatInRace("NZ", 500); BoatInRace[] boats = new BoatInRace[6];
boat1.setColour(Color.DARKVIOLET);
boat1.setCurrentPosition(new GPSCoordinate(0, 0));
int i = 0;
BoatInRace boat2 = new BoatInRace("TEST", 400); for (BoatInRace boat : Constants.OFFICIAL_AC35_COMPETITORS) {
boat2.setColour(Color.DARKRED); boat.setCurrentPosition(Constants.startLineMarker1);
boat2.setCurrentPosition(new GPSCoordinate(0, 0)); boats[i] = boat;
i++;
BoatInRace boat3 = new BoatInRace("TEST2", 350); }
boat3.setColour(Color.FUCHSIA);
boat3.setCurrentPosition(new GPSCoordinate(0, 0)); return boats;
return new BoatInRace[] {boat1, boat2, boat3};
} }

@ -19,6 +19,17 @@ public class BoatInRace extends Boat {
private Color colour; private Color colour;
private boolean finished = false; 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. * @return Returns the current position of the boat in a GPSCoordinate Class.
@ -61,15 +72,6 @@ public class BoatInRace extends Boat {
this.timeFinished = timeFinished; 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. * Gets the current leg that the boat is on.
* @return returns the leg the boat is on in a Leg class * @return returns the leg the boat is on in a Leg class

@ -21,7 +21,7 @@ public abstract class Race implements Runnable {
protected int boatsFinished = 0; 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 * Initailiser for Race
@ -62,7 +62,8 @@ public abstract class Race implements Runnable {
System.out.println("===================="); System.out.println("====================");
for (int i = 0; i < startingBoats.size(); i++) { for (int i = 0; i < startingBoats.size(); i++) {
if (startingBoats.get(i) != null) { 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)); startingBoats.get(i).setCurrentLeg(legs.get(0));
} }
} }
@ -119,7 +120,7 @@ public abstract class Race implements Runnable {
*/ */
protected void checkPosition(BoatInRace boat, long timeElapsed) { protected void checkPosition(BoatInRace boat, long timeElapsed) {
if (boat.getDistanceTravelledInLeg() > boat.getCurrentLeg().getDistance()){ 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 //boat has passed onto new leg
if (boat.getCurrentLeg().getName().equals("Finish")) { if (boat.getCurrentLeg().getName().equals("Finish")) {
//boat has finished //boat has finished
@ -128,6 +129,7 @@ public abstract class Race implements Runnable {
} else { } else {
boat.setDistanceTravelledInLeg(boat.getDistanceTravelledInLeg() - boat.getCurrentLeg().getDistance()); boat.setDistanceTravelledInLeg(boat.getDistanceTravelledInLeg() - boat.getCurrentLeg().getDistance());
Leg nextLeg = legs.get(boat.getCurrentLeg().getLegNumber() + 1); Leg nextLeg = legs.get(boat.getCurrentLeg().getLegNumber() + 1);
boat.setCurrentLeg(nextLeg); boat.setCurrentLeg(nextLeg);
boat.setDistanceTravelledInLeg(boat.getDistanceTravelledInLeg()); boat.setDistanceTravelledInLeg(boat.getDistanceTravelledInLeg());
} }

Loading…
Cancel
Save