You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
297 lines
7.3 KiB
297 lines
7.3 KiB
package shared.model;
|
|
|
|
|
|
import network.Messages.Enums.BoatStatusEnum;
|
|
|
|
/**
|
|
* Boat Model that is used to store information on the boats that are running in the race.
|
|
*/
|
|
public class Boat {
|
|
/**
|
|
* The name of the boat/team.
|
|
*/
|
|
private String name;
|
|
|
|
/**
|
|
* The current speed of the boat, in knots.
|
|
* TODO knots
|
|
*/
|
|
private double currentSpeed;
|
|
|
|
/**
|
|
* The current bearing/heading of the boat.
|
|
*/
|
|
private Bearing bearing;
|
|
|
|
/**
|
|
* The current position of the boat.
|
|
*/
|
|
private GPSCoordinate currentPosition;
|
|
|
|
/**
|
|
* The country or team abbreviation of the boat.
|
|
*/
|
|
private String country;
|
|
|
|
/**
|
|
* The source ID of the boat.
|
|
* This uniquely identifies an entity during a race.
|
|
*/
|
|
private int sourceID;
|
|
|
|
/**
|
|
* The leg of the race that the boat is currently on.
|
|
*/
|
|
private Leg currentLeg;
|
|
|
|
/**
|
|
* The distance, in meters, that the boat has travelled in the current leg.
|
|
* TODO meters
|
|
*/
|
|
private double distanceTravelledInLeg;
|
|
|
|
/**
|
|
* The time, in milliseconds, that has elapsed during the current leg.
|
|
* TODO milliseconds
|
|
*/
|
|
private long timeElapsedInCurrentLeg;
|
|
|
|
/**
|
|
* The timestamp, in milliseconds, of when the boat finished the race.
|
|
* Is -1 if it hasn't finished.
|
|
* TODO milliseconds
|
|
*/
|
|
private long timeFinished = -1;
|
|
|
|
/**
|
|
* The current status of the boat.
|
|
*/
|
|
private BoatStatusEnum status;
|
|
|
|
|
|
|
|
private long estimatedTime = 0;
|
|
|
|
|
|
/**
|
|
* Constructs a boat object with a given sourceID, name, country/team abbreviation, and polars table.
|
|
*
|
|
* @param sourceID The id of the boat
|
|
* @param name The name of the Boat.
|
|
* @param country The abbreviation or country code for the boat.
|
|
*/
|
|
public Boat(int sourceID, String name, String country) {
|
|
this.country = country;
|
|
this.name = name;
|
|
this.sourceID = sourceID;
|
|
|
|
this.bearing = Bearing.fromDegrees(0d);
|
|
|
|
this.status = BoatStatusEnum.UNDEFINED;
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Returns the name of the boat/team.
|
|
* @return Name of the boat/team.
|
|
*/
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
/**
|
|
* Sets the name of the boat/team.
|
|
* @param name Name of the boat/team.
|
|
*/
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
|
|
/**
|
|
* Returns the current speed of the boat, in knots.
|
|
* @return The current speed of the boat, in knots.
|
|
*/
|
|
public double getCurrentSpeed() {
|
|
return currentSpeed;
|
|
}
|
|
|
|
/**
|
|
* Sets the speed of the boat, in knots.
|
|
* @param currentSpeed The new speed of the boat, in knots.
|
|
*/
|
|
public void setCurrentSpeed(double currentSpeed) {
|
|
this.currentSpeed = currentSpeed;
|
|
}
|
|
|
|
|
|
/**
|
|
* Gets the country/team abbreviation of the boat.
|
|
* @return The country/team abbreviation of the boat.
|
|
*/
|
|
public String getCountry() {
|
|
return country;
|
|
}
|
|
|
|
/**
|
|
* Sets the country/team abbreviation of the boat.
|
|
* @param country The new country/team abbreviation for the boat.
|
|
*/
|
|
public void setCountry(String country) {
|
|
this.country = country;
|
|
}
|
|
|
|
|
|
/**
|
|
* Returns the source ID of the boat.
|
|
* @return The source ID of the boat.
|
|
*/
|
|
public int getSourceID() {
|
|
return sourceID;
|
|
}
|
|
|
|
/**
|
|
* Sets the source ID of the boat.
|
|
* @param sourceID The new source ID for the boat.
|
|
*/
|
|
public void setSourceID(int sourceID) {
|
|
this.sourceID = sourceID;
|
|
}
|
|
|
|
/**
|
|
* Returns the current leg of the race the boat is in.
|
|
* @return The current leg of the race the boat is in.
|
|
*/
|
|
public Leg getCurrentLeg() {
|
|
return currentLeg;
|
|
}
|
|
|
|
/**
|
|
* Sets the current leg of the race the boat is in.
|
|
* Clears time elapsed in current leg and distance travelled in current leg.
|
|
* @param currentLeg The new leg of the race the boat is in.
|
|
*/
|
|
public void setCurrentLeg(Leg currentLeg) {
|
|
this.currentLeg = currentLeg;
|
|
this.setTimeElapsedInCurrentLeg(0);
|
|
this.setDistanceTravelledInLeg(0);
|
|
}
|
|
|
|
|
|
/**
|
|
* Returns the distance, in meters, the boat has travelled in the current leg.
|
|
* @return The distance, in meters, the boat has travelled in the current leg.
|
|
*/
|
|
public double getDistanceTravelledInLeg() {
|
|
return distanceTravelledInLeg;
|
|
}
|
|
|
|
/**
|
|
* Sets the distance, in meters, the boat has travelled in the current leg.
|
|
* @param distanceTravelledInLeg The distance, in meters, the boat has travelled in the current leg.
|
|
*/
|
|
public void setDistanceTravelledInLeg(double distanceTravelledInLeg) {
|
|
this.distanceTravelledInLeg = distanceTravelledInLeg;
|
|
}
|
|
|
|
|
|
/**
|
|
* Returns the current position of the boat.
|
|
* @return The current position of the boat.
|
|
*/
|
|
public GPSCoordinate getCurrentPosition() {
|
|
return currentPosition;
|
|
}
|
|
|
|
/**
|
|
* Sets the current position of the boat.
|
|
* @param currentPosition The new position for the boat.
|
|
*/
|
|
public void setCurrentPosition(GPSCoordinate currentPosition) {
|
|
this.currentPosition = currentPosition;
|
|
}
|
|
|
|
|
|
/**
|
|
* Gets the timestamp, in milliseconds, at which the boat finished the race.
|
|
* @return The timestamp, in milliseconds, at which the boat finished the race.
|
|
*/
|
|
public long getTimeFinished() {
|
|
return timeFinished;
|
|
}
|
|
|
|
/**
|
|
* Sets the timestamp, in milliseconds, at which the boat finished the race.
|
|
* @param timeFinished The timestamp, in milliseconds, at which the boat finished the race.
|
|
*/
|
|
public void setTimeFinished(long timeFinished) {
|
|
this.timeFinished = timeFinished;
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Returns the current bearing of the boat.
|
|
* @return The current bearing of the boat.
|
|
*/
|
|
public Bearing getBearing() {
|
|
return bearing;
|
|
}
|
|
|
|
/**
|
|
* Sets the current bearing of the boat.
|
|
* @param bearing The new bearing of the boat.
|
|
*/
|
|
public void setBearing(Bearing bearing) {
|
|
this.bearing = bearing;
|
|
}
|
|
|
|
|
|
/**
|
|
* Returns the time, in milliseconds, that has elapsed since the boat started the current leg.
|
|
* @return The time, in milliseconds, that has elapsed since the boat started the current leg.
|
|
*/
|
|
public long getTimeElapsedInCurrentLeg() {
|
|
return timeElapsedInCurrentLeg;
|
|
}
|
|
|
|
/**
|
|
* Sets the time, in milliseconds, that has elapsed since the boat started the current leg.
|
|
* @param timeElapsedInCurrentLeg The new time, in milliseconds, that has elapsed since the boat started the current leg.
|
|
*/
|
|
public void setTimeElapsedInCurrentLeg(long timeElapsedInCurrentLeg) {
|
|
this.timeElapsedInCurrentLeg = timeElapsedInCurrentLeg;
|
|
}
|
|
|
|
|
|
/**
|
|
* Returns the status of the boat.
|
|
* @return The sttus of the boat.
|
|
*/
|
|
public BoatStatusEnum getStatus() {
|
|
return status;
|
|
}
|
|
|
|
/**
|
|
* Sets the status of the boat.
|
|
* @param status The new status of the boat.
|
|
*/
|
|
public void setStatus(BoatStatusEnum status) {
|
|
this.status = status;
|
|
}
|
|
|
|
|
|
|
|
|
|
public long getEstimatedTime() {
|
|
return estimatedTime;
|
|
}
|
|
|
|
public void setEstimatedTime(long estimatedTime) {
|
|
this.estimatedTime = estimatedTime;
|
|
}
|
|
}
|