Began implementing function to calculate boat's new coordinates

-Using haversine function
-current values being produced are too small

#implement #story[9]
This commit is contained in:
Erika Savell
2017-03-16 16:40:34 +13:00
parent 2551dd7362
commit 8090108b12
5 changed files with 77 additions and 27 deletions
@@ -0,0 +1,17 @@
package seng302.Model;
import org.junit.Test;
import seng302.GPSCoordinate;
/**
* Created by esa46 on 16/03/17.
*/
public class ConstantVelocityRaceTest {
@Test
public void travelling5nmNorthGivesCorrectNewCoordinates() {
GPSCoordinate oldPos = new GPSCoordinate(0, 0);
System.out.print(ConstantVelocityRace.calculate_position(oldPos, 1, 0).getLatitude());
}
}
+42
View File
@@ -0,0 +1,42 @@
package seng302.Model;
import org.junit.Test;
import seng302.GPSCoordinate;
import seng302.Model.BoatInRace;
import seng302.Model.ConstantVelocityRace;
import seng302.Model.Leg;
import static org.junit.Assert.assertTrue;
/**
* Created by esa46 on 15/03/17.
*/
public class RaceTest {
@Test
public void singleBoatRaceRunsAndFinishes() {
BoatInRace boat = new BoatInRace("NZ", 2500);
BoatInRace[] boats = new BoatInRace[] {boat};
Leg leg1 = new Leg("first leg", 1, new GPSCoordinate(0, 0), new GPSCoordinate(3, 4), 0);
Leg[] legs = new Leg[] {leg1};
ConstantVelocityRace race = new ConstantVelocityRace(boats, legs);
race.run();
assertTrue(race.finishingBoats.size() == 1);
}
@Test
public void fasterBoatFinishesFirst() {
BoatInRace fasterBoat = new BoatInRace("NZ", 2800);
BoatInRace slowerBoat = new BoatInRace("AU", 1800);
BoatInRace[] boats = new BoatInRace[] {slowerBoat, fasterBoat};
Leg leg1 = new Leg("first leg", 1, new GPSCoordinate(0, 0), new GPSCoordinate(3, 4), 0);
Leg[] legs = new Leg[] {leg1};
ConstantVelocityRace race = new ConstantVelocityRace(boats, legs);
race.run();
assertTrue(race.finishingBoats.get(0).getName() == "NZ");
assertTrue(race.finishingBoats.get(1).getName() == "AU");
}
}
-24
View File
@@ -1,24 +0,0 @@
package seng302;
import org.junit.Test;
import seng302.Model.BoatInRace;
import seng302.Model.ConstantVelocityRace;
import seng302.Model.Leg;
/**
* Created by esa46 on 15/03/17.
*/
public class RaceTest {
@Test
public void singleBoatRaceRunsAndFinishes(){
BoatInRace boat = new BoatInRace("NZ", 240);
BoatInRace[] boats = new BoatInRace[] {boat};
Leg leg1 = new Leg("first leg", 1, new GPSCoordinate(0, 0), new GPSCoordinate(3, 4), 0);
Leg[] legs = new Leg[] {leg1};
ConstantVelocityRace race = new ConstantVelocityRace(boats, legs);
race.run();
}
}