new method to check if a boat is between gates as well as updated the gps values to fit better with real life values
#story[1101]
This commit is contained in:
@@ -206,6 +206,7 @@ public class MockBoat extends Boat {
|
|||||||
/**
|
/**
|
||||||
* Check if a mark is on the port side of the boat
|
* Check if a mark is on the port side of the boat
|
||||||
* @param mark mark to be passed
|
* @param mark mark to be passed
|
||||||
|
* @return true if mark is on port side
|
||||||
*/
|
*/
|
||||||
public boolean isPortSide(Mark mark){
|
public boolean isPortSide(Mark mark){
|
||||||
//if this boat is lower than the mark check which way it is facing
|
//if this boat is lower than the mark check which way it is facing
|
||||||
@@ -219,6 +220,7 @@ public class MockBoat extends Boat {
|
|||||||
/**
|
/**
|
||||||
* Check if a mark is on the starboard side of the boat
|
* Check if a mark is on the starboard side of the boat
|
||||||
* @param mark mark to be passed
|
* @param mark mark to be passed
|
||||||
|
* @return true if mark is on starboard side
|
||||||
*/
|
*/
|
||||||
public boolean isStarboardSide(Mark mark){
|
public boolean isStarboardSide(Mark mark){
|
||||||
//if this boat is lower than the mark check which way it is facing
|
//if this boat is lower than the mark check which way it is facing
|
||||||
@@ -229,4 +231,18 @@ public class MockBoat extends Boat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to check if this boat is between a gate
|
||||||
|
* @param gate the gate to be checked
|
||||||
|
* @return true if the boat is between two marks that make up a gate
|
||||||
|
*/
|
||||||
|
public boolean isBetweenGate(CompoundMark gate){
|
||||||
|
if ((this.isPortSide(gate.getMark1()) && this.isStarboardSide(gate.getMark2())) ||
|
||||||
|
(this.isStarboardSide(gate.getMark2()) && this.isPortSide(gate.getMark1()))){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import mock.exceptions.InvalidPolarFileException;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import shared.model.Bearing;
|
import shared.model.Bearing;
|
||||||
|
import shared.model.CompoundMark;
|
||||||
import shared.model.GPSCoordinate;
|
import shared.model.GPSCoordinate;
|
||||||
import shared.model.Mark;
|
import shared.model.Mark;
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ public class MockBoatTest {
|
|||||||
private MockBoat firstTestBoat;
|
private MockBoat firstTestBoat;
|
||||||
|
|
||||||
private Mark markToTest;
|
private Mark markToTest;
|
||||||
|
private Mark markToTest2;
|
||||||
|
|
||||||
private GPSCoordinate highGPS;
|
private GPSCoordinate highGPS;
|
||||||
private GPSCoordinate middleGPS;
|
private GPSCoordinate middleGPS;
|
||||||
@@ -35,10 +37,11 @@ public class MockBoatTest {
|
|||||||
Polars polars = PolarParser.parse("mock/polars/acc_polars.csv");
|
Polars polars = PolarParser.parse("mock/polars/acc_polars.csv");
|
||||||
|
|
||||||
firstTestBoat = new MockBoat(1, "test", "NZ", polars);
|
firstTestBoat = new MockBoat(1, "test", "NZ", polars);
|
||||||
highGPS = new GPSCoordinate(100, 100);
|
highGPS = new GPSCoordinate(-64.854000, 32.296577);
|
||||||
middleGPS = new GPSCoordinate(100, 75);
|
middleGPS = new GPSCoordinate(-64.854000, 32.292500);
|
||||||
lowGPS = new GPSCoordinate(100, 50);
|
lowGPS = new GPSCoordinate(-64.854000, 32.290000);
|
||||||
markToTest = new Mark(1, "test MARK", middleGPS);
|
markToTest = new Mark(1, "test MARK", middleGPS);
|
||||||
|
markToTest2 = new Mark(2, "test MARK2", middleGPS);
|
||||||
}
|
}
|
||||||
catch (InvalidPolarFileException e) {
|
catch (InvalidPolarFileException e) {
|
||||||
fail("Couldn't parse polar file.");
|
fail("Couldn't parse polar file.");
|
||||||
@@ -153,4 +156,19 @@ public class MockBoatTest {
|
|||||||
|
|
||||||
assertEquals(firstTestBoat.isStarboardSide(markToTest), false);
|
assertEquals(firstTestBoat.isStarboardSide(markToTest), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if a boat is between a gate
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testIsBetweenGate(){
|
||||||
|
markToTest.setPosition(highGPS);
|
||||||
|
markToTest2.setPosition(lowGPS);
|
||||||
|
CompoundMark testGate = new CompoundMark(1, "test GATE", markToTest, markToTest2);
|
||||||
|
|
||||||
|
firstTestBoat.setCurrentPosition(middleGPS);
|
||||||
|
|
||||||
|
assertEquals(firstTestBoat.isBetweenGate(testGate), true);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user