|
|
|
@ -32,7 +32,7 @@ public class RaceTest {
|
|
|
|
ArrayList<Leg> legs = new ArrayList<>();
|
|
|
|
ArrayList<Leg> legs = new ArrayList<>();
|
|
|
|
legs.add(new Leg("Start", new GPSCoordinate(32.296577, -64.854304), new GPSCoordinate(32.293039, -64.843983), 0));
|
|
|
|
legs.add(new Leg("Start", new GPSCoordinate(32.296577, -64.854304), new GPSCoordinate(32.293039, -64.843983), 0));
|
|
|
|
legs.add(new Leg("Start", new GPSCoordinate(32.293039, -64.843983), new GPSCoordinate(32.284680, -64.850045), 1));
|
|
|
|
legs.add(new Leg("Start", new GPSCoordinate(32.293039, -64.843983), new GPSCoordinate(32.284680, -64.850045), 1));
|
|
|
|
Race race = new ConstantVelocityRace(boats, legs);
|
|
|
|
Race race = new ConstantVelocityRace(boats, legs, null, 1);
|
|
|
|
race.disableTimer();
|
|
|
|
race.disableTimer();
|
|
|
|
|
|
|
|
|
|
|
|
// Boats should finish in an order determined by their velocity
|
|
|
|
// Boats should finish in an order determined by their velocity
|
|
|
|
@ -52,7 +52,7 @@ public class RaceTest {
|
|
|
|
Leg leg = new Leg("Finish", new GPSCoordinate(0, 0), new GPSCoordinate(1, 1), 0);
|
|
|
|
Leg leg = new Leg("Finish", new GPSCoordinate(0, 0), new GPSCoordinate(1, 1), 0);
|
|
|
|
finishedBoat.setCurrentLeg(leg);
|
|
|
|
finishedBoat.setCurrentLeg(leg);
|
|
|
|
|
|
|
|
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[1], new ArrayList<Leg>());
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[1], new ArrayList<Leg>(), null, 1);
|
|
|
|
assertEquals(race.boatsFinished, 0);
|
|
|
|
assertEquals(race.boatsFinished, 0);
|
|
|
|
|
|
|
|
|
|
|
|
race.checkPosition(finishedBoat, 100);
|
|
|
|
race.checkPosition(finishedBoat, 100);
|
|
|
|
@ -68,7 +68,7 @@ public class RaceTest {
|
|
|
|
Leg leg = new Leg("Finish", new GPSCoordinate(0, 0), new GPSCoordinate(1, 1), 0);
|
|
|
|
Leg leg = new Leg("Finish", new GPSCoordinate(0, 0), new GPSCoordinate(1, 1), 0);
|
|
|
|
unFinishedBoat.setCurrentLeg(leg);
|
|
|
|
unFinishedBoat.setCurrentLeg(leg);
|
|
|
|
|
|
|
|
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[1], new ArrayList<Leg>());
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[1], new ArrayList<Leg>(), null, 1);
|
|
|
|
assertEquals(race.boatsFinished, 0);
|
|
|
|
assertEquals(race.boatsFinished, 0);
|
|
|
|
|
|
|
|
|
|
|
|
race.checkPosition(unFinishedBoat, 100);
|
|
|
|
race.checkPosition(unFinishedBoat, 100);
|
|
|
|
@ -87,7 +87,7 @@ public class RaceTest {
|
|
|
|
legs.add(leg2);
|
|
|
|
legs.add(leg2);
|
|
|
|
legs.add(leg2);
|
|
|
|
legs.add(leg2);
|
|
|
|
|
|
|
|
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[1], legs);
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[1], legs, null, 1);
|
|
|
|
|
|
|
|
|
|
|
|
BoatInRace unFinishedBoat = new BoatInRace("Test", 10, Color.ALICEBLUE, "tt");
|
|
|
|
BoatInRace unFinishedBoat = new BoatInRace("Test", 10, Color.ALICEBLUE, "tt");
|
|
|
|
unFinishedBoat.setDistanceTravelledInLeg(100);
|
|
|
|
unFinishedBoat.setDistanceTravelledInLeg(100);
|
|
|
|
@ -102,7 +102,7 @@ public class RaceTest {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void timerDelaysByHalfSecond() {
|
|
|
|
public void timerDelaysByHalfSecond() {
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[1], new ArrayList<>());
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[1], new ArrayList<>(), null, 1);
|
|
|
|
race.PRERACE_TIME = 500;
|
|
|
|
race.PRERACE_TIME = 500;
|
|
|
|
|
|
|
|
|
|
|
|
long timeStarted = System.currentTimeMillis();
|
|
|
|
long timeStarted = System.currentTimeMillis();
|
|
|
|
@ -126,7 +126,7 @@ public class RaceTest {
|
|
|
|
BoatInRace boat4 = new BoatInRace("test", vel4, Color.ALICEBLUE, "tt");
|
|
|
|
BoatInRace boat4 = new BoatInRace("test", vel4, Color.ALICEBLUE, "tt");
|
|
|
|
BoatInRace[] boats = new BoatInRace[]{boat1, boat2, boat3, boat4};
|
|
|
|
BoatInRace[] boats = new BoatInRace[]{boat1, boat2, boat3, boat4};
|
|
|
|
|
|
|
|
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(boats, new ArrayList<Leg>(), scaleFactor);
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(boats, new ArrayList<Leg>(), null, scaleFactor);
|
|
|
|
assertEquals(race.getStartingBoats().get(0).getScaledVelocity(), vel1 * scaleFactor, 1e-6);
|
|
|
|
assertEquals(race.getStartingBoats().get(0).getScaledVelocity(), vel1 * scaleFactor, 1e-6);
|
|
|
|
assertEquals(race.getStartingBoats().get(1).getScaledVelocity(), vel2 * scaleFactor, 1e-6);
|
|
|
|
assertEquals(race.getStartingBoats().get(1).getScaledVelocity(), vel2 * scaleFactor, 1e-6);
|
|
|
|
assertEquals(race.getStartingBoats().get(2).getScaledVelocity(), vel3 * scaleFactor, 1e-6);
|
|
|
|
assertEquals(race.getStartingBoats().get(2).getScaledVelocity(), vel3 * scaleFactor, 1e-6);
|
|
|
|
@ -136,7 +136,7 @@ public class RaceTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void scalerScalesRaceClockTo1MinCorrectly() {
|
|
|
|
public void scalerScalesRaceClockTo1MinCorrectly() {
|
|
|
|
int scaleFactor = 10;
|
|
|
|
int scaleFactor = 10;
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[5], new ArrayList<Leg>(), scaleFactor);
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[5], new ArrayList<Leg>(), null, scaleFactor);
|
|
|
|
race.totalTimeElapsed = 6000; //6 seconds
|
|
|
|
race.totalTimeElapsed = 6000; //6 seconds
|
|
|
|
assertTrue(race.calcTimer().equals("Race clock: 00:01:00"));
|
|
|
|
assertTrue(race.calcTimer().equals("Race clock: 00:01:00"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -144,7 +144,7 @@ public class RaceTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void scalerScalesRaceClockHoursMinutesAndSecondsCorrectly() {
|
|
|
|
public void scalerScalesRaceClockHoursMinutesAndSecondsCorrectly() {
|
|
|
|
int scaleFactor = 3;
|
|
|
|
int scaleFactor = 3;
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[5], new ArrayList<Leg>(), scaleFactor);
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[5], new ArrayList<Leg>(), null, scaleFactor);
|
|
|
|
race.totalTimeElapsed = 3213000;
|
|
|
|
race.totalTimeElapsed = 3213000;
|
|
|
|
assertTrue(race.calcTimer().equals("Race clock: 02:40:39"));
|
|
|
|
assertTrue(race.calcTimer().equals("Race clock: 02:40:39"));
|
|
|
|
|
|
|
|
|
|
|
|
|