@ -9,12 +9,29 @@ public class Event {
private int time ;
private int time ;
private RaceMarker goalMarker ;
private RaceMarker goalMarker ;
/ * *
* Initaliser for Racemaker without a goal node ( such as the Finish line ) .
* @param raceMarker current Racemarker that has just been passed .
* @param boat Boat that has been passed .
* @param time time in seconds that the event occurred .
* @see seng302 . RaceMarker
* @see seng302 . Boat
* /
public Event ( RaceMarker raceMarker , Boat boat , int time ) {
public Event ( RaceMarker raceMarker , Boat boat , int time ) {
this . raceMarker = raceMarker ;
this . raceMarker = raceMarker ;
this . boat = boat ;
this . boat = boat ;
this . time = time ;
this . time = time ;
}
}
/ * *
* Initaliser for Racemaker with a goal node .
* @param raceMarker current Racemarker that has just been passed .
* @param boat Boat that has been passed .
* @param time time in seconds that the event occurred .
* @param goalMarker the next marker that the boat is aiming for .
* @see seng302 . RaceMarker
* @see seng302 . Boat
* /
public Event ( RaceMarker raceMarker , Boat boat , int time , RaceMarker goalMarker ) {
public Event ( RaceMarker raceMarker , Boat boat , int time , RaceMarker goalMarker ) {
this . raceMarker = raceMarker ;
this . raceMarker = raceMarker ;
this . boat = boat ;
this . boat = boat ;
@ -22,24 +39,44 @@ public class Event {
this . goalMarker = goalMarker ;
this . goalMarker = goalMarker ;
}
}
/ * *
* Calculates the bearing of the travel via map coordinates of the raceMarkers
* @return
* /
public double calculateHeading ( ) {
public double calculateHeading ( ) {
//to be changed to coordinates when used to match reality.
//to be changed to coordinates when used to match reality.
double thetaHat = Math . atan2 ( ( goalMarker . getLatitude ( ) - raceMarker . getLatitude ( ) ) , ( goalMarker . getLongitude ( ) - raceMarker . getLongitude ( ) ) ) ;
double thetaHat = Math . atan2 ( ( goalMarker . getLatitude ( ) - raceMarker . getLatitude ( ) ) , ( goalMarker . getLongitude ( ) - raceMarker . getLongitude ( ) ) ) ;
return thetaHat > = 0 ? Math . toDegrees ( thetaHat ) : Math . toDegrees ( thetaHat + 2 * Math . PI ) ;
return thetaHat > = 0 ? Math . toDegrees ( thetaHat ) : Math . toDegrees ( thetaHat + 2 * Math . PI ) ;
}
}
/ * *
*
* @return the raceMarker that the boat has just passed .
* /
public RaceMarker getRaceMarker ( ) {
public RaceMarker getRaceMarker ( ) {
return raceMarker ;
return raceMarker ;
}
}
/ * *
*
* @return the boat that this event occured for .
* /
public Boat getBoat ( ) {
public Boat getBoat ( ) {
return boat ;
return boat ;
}
}
/ * *
*
* @return the time the event occurred
* /
public int getTime ( ) {
public int getTime ( ) {
return this . time ;
return this . time ;
}
}
/ * *
*
* @return the event as a string in format { Boat Name } passed { RaceMarker Name } at { Time Event Occurred } seconds at heading { Heading } .
* /
public String toString ( ) {
public String toString ( ) {
String stringToReturn = boat . getName ( ) + " passed " + raceMarker . toString ( ) + " at " + time + " seconds" ;
String stringToReturn = boat . getName ( ) + " passed " + raceMarker . toString ( ) + " at " + time + " seconds" ;
if ( goalMarker ! = null ) {
if ( goalMarker ! = null ) {