|
|
|
@ -30,16 +30,16 @@ public class RaceTest {
|
|
|
|
new BoatInRace("AU", 2800, Color.BEIGE, "AU")
|
|
|
|
new BoatInRace("AU", 2800, Color.BEIGE, "AU")
|
|
|
|
};
|
|
|
|
};
|
|
|
|
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);
|
|
|
|
race.disableTimer();
|
|
|
|
race.disableTimer();
|
|
|
|
|
|
|
|
|
|
|
|
// Boats should finish in an order determined by their velocity
|
|
|
|
// Boats should finish in an order determined by their velocity
|
|
|
|
Arrays.sort(boats, (a,b) -> (int)(b.getVelocity()-a.getVelocity()));
|
|
|
|
Arrays.sort(boats, (a, b) -> (int) (b.getVelocity() - a.getVelocity()));
|
|
|
|
race.run();
|
|
|
|
race.run();
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < boats.length; i++)
|
|
|
|
for (int i = 0; i < boats.length; i++)
|
|
|
|
assertTrue(boats[i].equals(race.getStartingBoats().get(i)));
|
|
|
|
assertTrue(boats[i].equals(race.getStartingBoats().get(i)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -84,7 +84,8 @@ public class RaceTest {
|
|
|
|
Leg leg1 = new Leg("1", new GPSCoordinate(0, 0), new GPSCoordinate(1, 1), 0);
|
|
|
|
Leg leg1 = new Leg("1", new GPSCoordinate(0, 0), new GPSCoordinate(1, 1), 0);
|
|
|
|
Leg leg2 = new Leg("2", new GPSCoordinate(0, 0), new GPSCoordinate(1, 1), 1);
|
|
|
|
Leg leg2 = new Leg("2", new GPSCoordinate(0, 0), new GPSCoordinate(1, 1), 1);
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
@ -114,7 +115,7 @@ public class RaceTest {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void scalerScalesVelocityCorrectly() {
|
|
|
|
public void scalerScalesVelocityCorrectly() {
|
|
|
|
|
|
|
|
|
|
|
|
int scaleFactor = 0;
|
|
|
|
int scaleFactor = 3;
|
|
|
|
float vel1 = 0;
|
|
|
|
float vel1 = 0;
|
|
|
|
float vel2 = (float) 1.999;
|
|
|
|
float vel2 = (float) 1.999;
|
|
|
|
float vel3 = (float) 32.5;
|
|
|
|
float vel3 = (float) 32.5;
|
|
|
|
@ -123,12 +124,29 @@ public class RaceTest {
|
|
|
|
BoatInRace boat2 = new BoatInRace("test", vel2, Color.ALICEBLUE, "tt");
|
|
|
|
BoatInRace boat2 = new BoatInRace("test", vel2, Color.ALICEBLUE, "tt");
|
|
|
|
BoatInRace boat3 = new BoatInRace("test", vel3, Color.ALICEBLUE, "tt");
|
|
|
|
BoatInRace boat3 = new BoatInRace("test", vel3, Color.ALICEBLUE, "tt");
|
|
|
|
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>(), scaleFactor);
|
|
|
|
assertEquals(race.getStartingBoats().get(0).getScaledVelocity(), vel1 * scaleFactor, 1e-8);
|
|
|
|
assertEquals(race.getStartingBoats().get(0).getScaledVelocity(), vel1 * scaleFactor, 1e-6);
|
|
|
|
assertEquals(race.getStartingBoats().get(1).getScaledVelocity(), vel2 * scaleFactor, 1e-8);
|
|
|
|
assertEquals(race.getStartingBoats().get(1).getScaledVelocity(), vel2 * scaleFactor, 1e-6);
|
|
|
|
assertEquals(race.getStartingBoats().get(2).getScaledVelocity(), vel3 * scaleFactor, 1e-8);
|
|
|
|
assertEquals(race.getStartingBoats().get(2).getScaledVelocity(), vel3 * scaleFactor, 1e-6);
|
|
|
|
assertEquals(race.getStartingBoats().get(3).getScaledVelocity(), vel4 * scaleFactor, 1e-8);
|
|
|
|
assertEquals(race.getStartingBoats().get(3).getScaledVelocity(), vel4 * scaleFactor, 1e-6);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void scalerScalesRaceClockTo1MinCorrectly() {
|
|
|
|
|
|
|
|
int scaleFactor = 10;
|
|
|
|
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[5], new ArrayList<Leg>(), scaleFactor);
|
|
|
|
|
|
|
|
race.totalTimeElapsed = 6000; //6 seconds
|
|
|
|
|
|
|
|
assertTrue(race.calcTimer().equals("Race clock: 00:01:00"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void scalerScalesRaceClockHoursMinutesAndSecondsCorrectly() {
|
|
|
|
|
|
|
|
int scaleFactor = 3;
|
|
|
|
|
|
|
|
ConstantVelocityRace race = new ConstantVelocityRace(new BoatInRace[5], new ArrayList<Leg>(), scaleFactor);
|
|
|
|
|
|
|
|
race.totalTimeElapsed = 3213000;
|
|
|
|
|
|
|
|
assertTrue(race.calcTimer().equals("Race clock: 02:40:39"));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|