Fixing merge and resulting failing tests

#fix #story[16]
This commit is contained in:
Erika Savell
2017-03-25 19:01:03 +13:00
parent ac558746a0
commit f5ba7c95c8
8 changed files with 49 additions and 67 deletions
-9
View File
@@ -14,7 +14,6 @@ public class Boat {
private StringProperty name;
private double velocity;
private double scaledVelocity;
private StringProperty velocityProp;
private String abbrev;
@@ -51,14 +50,6 @@ public class Boat {
}
public double getScaledVelocity() {
return scaledVelocity;
}
public void setScaledVelocity(double velocity) {
this.scaledVelocity = velocity;
}
/**
*
* @return The Name of the boat.
@@ -15,6 +15,7 @@ import seng302.GPSCoordinate;
public class BoatInRace extends Boat {
private Leg currentLeg;
private double scaledVelocity;
private double distanceTravelledInLeg;
private GPSCoordinate currentPosition;
private long timeFinished;
@@ -34,6 +35,14 @@ public class BoatInRace extends Boat {
currentLegName = new SimpleStringProperty("");
}
public double getScaledVelocity() {
return scaledVelocity;
}
public void setScaledVelocity(double velocity) {
this.scaledVelocity = velocity;
}
/**
*
* @return Returns the current position of the boat in a GPSCoordinate Class.
@@ -23,17 +23,9 @@ public class ConstantVelocityRace extends Race {
*/
public ConstantVelocityRace(BoatInRace[] startingBoats, ArrayList<Leg> marks, RaceController controller, int scaleFactor) {
super(startingBoats, marks, controller);
setScaleFactor(scaleFactor);
super(startingBoats, marks, controller, scaleFactor);
}
public ConstantVelocityRace(BoatInRace[] startingBoats, ArrayList<Leg> marks) {
super(startingBoats, marks);
}
public ConstantVelocityRace(BoatInRace[] startingBoats, ArrayList<Leg> marks, int scaleFactor) {
super(startingBoats, marks, scaleFactor);
}
protected void updatePosition(BoatInRace boat, int millisecondsElapsed) {
@@ -43,7 +35,6 @@ public class ConstantVelocityRace extends Race {
boolean finish = boat.getCurrentLeg().getName().equals("Finish");
if (!finish) {
boat.setDistanceTravelledInLeg(totalDistanceTravelled);
boat.setCurrentPosition(calculatePosition(boat.getCurrentLeg().getStartGraphCoordinate(),
totalDistanceTravelled, boat.calculateAzimuth()));
-1
View File
@@ -28,7 +28,6 @@ public class Leg {
this.endGPSCoordinate = end;
this.legNumber = number;
this.distance = calculateDistance();
System.out.println("Distance of leg " + name + " is " + Double.toString(distance));
}
/**
+12 -20
View File
@@ -20,10 +20,10 @@ public abstract class Race implements Runnable {
protected int boatsFinished = 0;
protected long totalTimeElapsed;
protected int scaleFactor = 15;
protected int scaleFactor;
private int SLEEP_TIME = 100; //time in milliseconds to pause in a paced loop
protected int PRERACE_TIME = 10000;//Integer.MAX_VALUE; //time in milliseconds to pause during pre-race
protected int PRERACE_TIME = 100;//Integer.MAX_VALUE; //time in milliseconds to pause during pre-race
private boolean timerEnabled = true;
/**
@@ -31,26 +31,27 @@ public abstract class Race implements Runnable {
* @param boats Takes in an array of boats that are participating in the race.
* @param legs Number of marks in order that the boats pass in order to complete the race.
*/
public Race(BoatInRace[] boats, ArrayList<Leg> legs, RaceController controller) {
for (BoatInRace boat : boats) {
boat.setScaledVelocity(boat.getVelocity() * scaleFactor);
public Race(BoatInRace[] boats, ArrayList<Leg> legs, RaceController controller, int scaleFactor) {
if (boats.length > 0) {
for (BoatInRace boat : boats) {
if (boat != null) {
boat.setScaledVelocity(boat.getVelocity() * scaleFactor);
}
}
}
this.startingBoats = FXCollections.observableArrayList(boats);
this.legs = legs;
this.legs.add(new Leg("Finish", this.legs.size()));
this.controller = controller;
this.scaleFactor = scaleFactor;
}
/**
* Constructor for Race class
* @param boats boats participating in the race.
* @param marks legs that there are in the race.
* @param legs legs that there are in the race.
*/
public Race(BoatInRace[] boats, ArrayList<Leg> marks) {
this(boats, marks, null);
}
public Race(BoatInRace[] boats, ArrayList<Leg> legs, int scaleFactor) {
if (boats.length > 0) {
for (BoatInRace boat : boats) {
@@ -66,11 +67,6 @@ public abstract class Race implements Runnable {
}
public void setScaleFactor(int scaleFactor) {
this.scaleFactor = scaleFactor;
}
/**
* Runnable for the thread.
*/
@@ -90,12 +86,8 @@ public abstract class Race implements Runnable {
*/
private void preRace() {
//show the boats participating.
System.out.println("Boats Participating:");
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");
startingBoats.get(i).setCurrentLeg(legs.get(0));
}
}
@@ -123,7 +115,7 @@ public abstract class Race implements Runnable {
hours = minutes / 60;
minutes = minutes % 60;
if (controller != null) {
updateTime(String.format("Time until race starts: -%02d:%02d:%02d", hours, minutes, remainingSeconds));
updateTime(String.format("Race clock: -%02d:%02d:%02d", hours, minutes, remainingSeconds));
}
}
try {
+1 -1
View File
@@ -60,7 +60,7 @@
</Label>
</children>
</GridPane>
<SplitPane fx:id="ongoingRacePane" dividerPositions="0.5" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<SplitPane fx:id="ongoingRacePane" dividerPositions="0.70" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<AnchorPane fx:id="canvasBase" prefHeight="581.0" prefWidth="537.0">
<children>