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.
94 lines
2.1 KiB
94 lines
2.1 KiB
package SharedModel;
|
|
|
|
import javafx.beans.property.SimpleStringProperty;
|
|
import javafx.beans.property.StringProperty;
|
|
|
|
/**
|
|
* Created by fwy13 on 3/03/17.
|
|
*/
|
|
public class Boat {
|
|
|
|
private StringProperty name;
|
|
private double velocity;
|
|
private StringProperty velocityProp;
|
|
private String abbrev;
|
|
private int sourceID;
|
|
|
|
/**
|
|
* Boat initialiser which keeps all of the information of the boat.
|
|
*
|
|
* @param name Name of the Boat.
|
|
* @param velocity Speed in m/s that the boat travels at.
|
|
* @param abbrev nam abbreviation
|
|
* @param sourceID id of boat
|
|
*/
|
|
public Boat(String name, double velocity, String abbrev, int sourceID) {
|
|
this.velocity = velocity;
|
|
this.velocityProp = new SimpleStringProperty(String.valueOf(Math.round(velocity)));
|
|
this.abbrev = abbrev;
|
|
this.name = new SimpleStringProperty(name);
|
|
this.sourceID = sourceID;
|
|
}
|
|
|
|
/**
|
|
* @return Name of the boat
|
|
*/
|
|
public StringProperty getName() {
|
|
return name;
|
|
}
|
|
|
|
/**
|
|
* Sets the boat name
|
|
*
|
|
* @param name of boat
|
|
*/
|
|
public void setName(String name) {
|
|
this.name.setValue(name);
|
|
}
|
|
|
|
/**
|
|
* @return Speed of the boat.
|
|
*/
|
|
public double getVelocity() {
|
|
return velocity;
|
|
}
|
|
|
|
/**
|
|
* Sets the speed of the boat in knots.
|
|
*
|
|
* @param velocity speed in knots
|
|
*/
|
|
public void setVelocity(double velocity) {
|
|
this.velocity = velocity;
|
|
this.velocityProp.setValue(String.valueOf(Math.round(velocity)));
|
|
}
|
|
|
|
public int getSourceID() {
|
|
return sourceID;
|
|
}
|
|
|
|
/**
|
|
* Print method prints the name of the boat
|
|
*
|
|
* @return Name of the boat.
|
|
*/
|
|
public String toString() {
|
|
return getName().getValue();
|
|
}
|
|
|
|
/**
|
|
* @return Velocity String Property of the boat
|
|
*/
|
|
public StringProperty getVelocityProp() {
|
|
return velocityProp;
|
|
}
|
|
|
|
/**
|
|
* @return Abbreviation of the boat
|
|
*/
|
|
public String getAbbrev() {
|
|
return abbrev;
|
|
}
|
|
|
|
}
|