Test that boat velocities are being scaled correctly added
#story[16] #implement
This commit is contained in:
@@ -30,6 +30,10 @@ public class ConstantVelocityRace extends Race {
|
||||
super(startingBoats, marks);
|
||||
}
|
||||
|
||||
public ConstantVelocityRace(BoatInRace[] startingBoats, ArrayList<Leg> marks, int scaleFactor) {
|
||||
super(startingBoats, marks, scaleFactor);
|
||||
}
|
||||
|
||||
protected void updatePosition(BoatInRace boat, int millisecondsElapsed) {
|
||||
|
||||
//distanceTravelled = velocity (nm p hr) * time taken to update loop
|
||||
|
||||
@@ -2,12 +2,9 @@ package seng302.Model;
|
||||
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableArray;
|
||||
import javafx.collections.ObservableList;
|
||||
import seng302.Controllers.RaceController;
|
||||
import seng302.GPSCoordinate;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -22,8 +19,8 @@ public abstract class Race implements Runnable {
|
||||
protected RaceController controller;
|
||||
protected int boatsFinished = 0;
|
||||
protected long totalTimeElapsed;
|
||||
protected int scale_factor = 15;
|
||||
|
||||
protected int scaleFactor = 1;
|
||||
|
||||
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
|
||||
@@ -36,7 +33,7 @@ public abstract class Race implements Runnable {
|
||||
*/
|
||||
public Race(BoatInRace[] boats, ArrayList<Leg> legs, RaceController controller) {
|
||||
for (BoatInRace boat : boats) {
|
||||
boat.setScaledVelocity(boat.getVelocity() * scale_factor);
|
||||
boat.setScaledVelocity(boat.getVelocity() * scaleFactor);
|
||||
}
|
||||
|
||||
this.startingBoats = FXCollections.observableArrayList(boats);
|
||||
@@ -54,6 +51,22 @@ public abstract class Race implements Runnable {
|
||||
this(boats, marks, null);
|
||||
}
|
||||
|
||||
public Race(BoatInRace[] boats, ArrayList<Leg> legs, int scaleFactor) {
|
||||
for (BoatInRace boat : boats) {
|
||||
boat.setScaledVelocity(boat.getVelocity() * scaleFactor);
|
||||
}
|
||||
this.startingBoats = FXCollections.observableArrayList(boats);
|
||||
this.legs = legs;
|
||||
this.legs.add(new Leg("Finish", this.legs.size()));
|
||||
this.scaleFactor = scaleFactor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setScaleFactor(int scaleFactor) {
|
||||
this.scaleFactor = scaleFactor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runnable for the thread.
|
||||
*/
|
||||
@@ -122,7 +135,7 @@ public abstract class Race implements Runnable {
|
||||
long hours;
|
||||
|
||||
currentTimeInSeconds = totalTimeElapsed / 1000;
|
||||
long scaledTimeInSeconds = currentTimeInSeconds * scale_factor;
|
||||
long scaledTimeInSeconds = currentTimeInSeconds * scaleFactor;
|
||||
minutes = scaledTimeInSeconds / 60;
|
||||
remainingSeconds = scaledTimeInSeconds % 60;
|
||||
hours = minutes / 60;
|
||||
|
||||
Reference in New Issue
Block a user