added new methods to the mock boats to let them check which side a mark is on to them
#story[1101]
This commit is contained in:
@@ -203,4 +203,28 @@ public class MockBoat extends Boat {
|
||||
return distanceTravelledMeters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a mark is on the port side of the boat
|
||||
*/
|
||||
public boolean isPortSide(Mark mark){
|
||||
//if this boat is lower than the mark check which way it is facing
|
||||
if(this.getCurrentPosition().getLongitude() < mark.getPosition().getLongitude()){
|
||||
return this.getBearing().degrees() <= 180;
|
||||
}else{
|
||||
return this.getBearing().degrees() > 180;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a mark is on the starboard side of the boat
|
||||
*/
|
||||
public boolean isStarboardSide(Mark mark){
|
||||
//if this boat is lower than the mark check which way it is facing
|
||||
if(this.getCurrentPosition().getLongitude() < mark.getPosition().getLongitude()){
|
||||
return this.getBearing().degrees() >= 180;
|
||||
}else{
|
||||
return this.getBearing().degrees() < 180;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user