Added Javadoc Strings for Some functions

main
YaFedImYaEatIm 9 years ago
parent 9e00e3666f
commit 724f63956a

@ -22,7 +22,7 @@ public class Airline{
private Country country = null; private Country country = null;
/** /**
* Constructor * Constructor for Airline when pulled from the database.
* *
* @param ID * @param ID
* @param name * @param name
@ -45,7 +45,16 @@ public class Airline{
this.routes = new ArrayList<Route>(); this.routes = new ArrayList<Route>();
} }
/**
* Constructor for Airline without ID this will be set later by the dataset from the dataset.
* @param name
* @param alias
* @param IATA
* @param ICAO
* @param callSign
* @param countryName
* @param active
*/
public Airline(String name, String alias, String IATA, String ICAO, String callSign, String countryName, String active){ public Airline(String name, String alias, String IATA, String ICAO, String callSign, String countryName, String active){
this.ID = -1; this.ID = -1;
this.IATA = IATA; this.IATA = IATA;
@ -255,6 +264,9 @@ public class Airline{
if (this.name.equals(airline.getName())){ if (this.name.equals(airline.getName())){
throw new DataException("This Airline Name already Exists, Please Choose Another."); throw new DataException("This Airline Name already Exists, Please Choose Another.");
} }
if (this.name.equals("")){
throw new DataException("This Airline Name cannot be Empty");
}
if (!this.IATA.equals("") && this.IATA.equals(airline.getIATA())){ if (!this.IATA.equals("") && this.IATA.equals(airline.getIATA())){
throw new DataException("This IATA Code already Exists, Please Choose Another."); throw new DataException("This IATA Code already Exists, Please Choose Another.");
} }
@ -273,7 +285,7 @@ public class Airline{
*/ */
@Override @Override
public String toString(){ public String toString(){
return name; return name + ", IATA:" + IATA + ", ICAO: " + ICAO;
} }
} }

@ -89,6 +89,11 @@ public class Airport {
public void setID(int iD) { public void setID(int iD) {
this.ID = iD; this.ID = iD;
} }
/**
* Sets the Name of the Airport.
* @param name
*/
public void setName(String name){ public void setName(String name){
this.name = name; this.name = name;
} }
@ -148,10 +153,18 @@ public class Airport {
} }
} }
/**
* gets the country name
* @return
*/
public String getCountryName() { public String getCountryName() {
return countryName; return countryName;
} }
/**
* sets the country name
* @param countryName
*/
public void setCountryName(String countryName) { public void setCountryName(String countryName) {
this.countryName = countryName; this.countryName = countryName;
} }
@ -194,13 +207,6 @@ public class Airport {
public String getICAO(){ public String getICAO(){
return ICAO; return ICAO;
} }
/**
* gets the IATA/FFA of the airport
* @return IATA/FFA Code
*/
// public String IATA_FFA(){
// return IATA_FFA;
// }
/** /**
* gets the altitude of the airport * gets the altitude of the airport
* @return Altitude of Airport * @return Altitude of Airport
@ -254,7 +260,10 @@ public class Airport {
return country; return country;
} }
//JavaDoc needed /**
* gets the timezone of the Airport
* @return
*/
public Double getTimezone() { public Double getTimezone() {
if (this.city != null) { if (this.city != null) {
return this.city.getTimezone(); return this.city.getTimezone();
@ -262,7 +271,11 @@ public class Airport {
return 0.0; return 0.0;
} }
} }
//JavaDoc needed
/**
* gets the DST of the Country the Airport is in.
* @return
*/
public String getDST() { public String getDST() {
if (this.country != null) { if (this.country != null) {
return this.country.getDST(); return this.country.getDST();
@ -270,7 +283,11 @@ public class Airport {
return ""; return "";
} }
} }
//JavaDoc needed
/**
* gets the timezone in Olson format of the country the airport is in
* @return
*/
public String getTz() { public String getTz() {
if (this.city != null) { if (this.city != null) {
return this.city.getTimeOlson(); return this.city.getTimeOlson();
@ -364,6 +381,12 @@ public class Airport {
distance = 6371 * c; distance = 6371 * c;
return distance; return distance;
} }
/**
* Checks if the airport is a semi duplicate of this class. Used to see if it passes to enter into the Database.
* @param airport
* @throws DataException
*/
public void hasDuplicate(Airport airport) throws DataException{ public void hasDuplicate(Airport airport) throws DataException{
if (airport.getName().equals("") || airport.getName().equals(this.name)){ if (airport.getName().equals("") || airport.getName().equals(this.name)){
throw new DataException("Airport Name already Exists, Please Choose Another."); throw new DataException("Airport Name already Exists, Please Choose Another.");
@ -378,7 +401,6 @@ public class Airport {
/** /**
* Information of the airport returned in String format. * Information of the airport returned in String format.
*/ */
@Override @Override
public String toString(){ public String toString(){
return this.cityName +" Airport has ICAO: "+this.ICAO+", IATA/FFA: "+this.IATA_FFA+" and is located at ("+this.latitude+", "+this.longitude return this.cityName +" Airport has ICAO: "+this.ICAO+", IATA/FFA: "+this.IATA_FFA+" and is located at ("+this.latitude+", "+this.longitude

@ -8,7 +8,14 @@ public class City {
private double timezone; private double timezone;
private String timeOlson; private String timeOlson;
private ArrayList<Airport> airports; private ArrayList<Airport> airports;
/**
* City Constructor
* @param name
* @param country
* @param timezone
* @param timeOlson
*/
public City(String name, String country, double timezone, String timeOlson){ public City(String name, String country, double timezone, String timeOlson){
this.name = name; this.name = name;
this.country = country; this.country = country;
@ -16,23 +23,43 @@ public class City {
this.timeOlson = timeOlson; this.timeOlson = timeOlson;
this.airports = new ArrayList<Airport>(); this.airports = new ArrayList<Airport>();
} }
/**
* Sets Name of the City
* @param name
*/
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/**
* Sets Country that the city is in.
* @param country
*/
public void setCountry(String country){ public void setCountry(String country){
this.country = country; this.country = country;
} }
/**
* Set Timezone that the City is in.
* @param timezone
*/
public void setTimezone(double timezone) { public void setTimezone(double timezone) {
this.timezone = timezone; this.timezone = timezone;
} }
/**
* Sets the time olson the city is in.
* @param timeOlson
*/
public void setTimeOlson(String timeOlson) { public void setTimeOlson(String timeOlson) {
this.timeOlson = timeOlson; this.timeOlson = timeOlson;
} }
/**
* Sets the airports the are in the city
* @param airports
*/
public void setAirports(ArrayList<Airport> airports) { public void setAirports(ArrayList<Airport> airports) {
this.airports = new ArrayList<Airport>(); this.airports = new ArrayList<Airport>();
for (int i = 0; i < airports.size(); i ++) { for (int i = 0; i < airports.size(); i ++) {
@ -40,46 +67,81 @@ public class City {
} }
} }
/**
* Gets the name of the city.
* @return
*/
public String getName(){ public String getName(){
return name; return name;
} }
/**
* Gets the Country that the city is in.
* @return
*/
public String getCountry(){ public String getCountry(){
return country; return country;
} }
/**
* gets the Timezone that the City is in.
* @return
*/
public double getTimezone(){ public double getTimezone(){
return timezone; return timezone;
} }
/**
* Gets the Timezone in Olson format the City is in.
* @return
*/
public String getTimeOlson(){ public String getTimeOlson(){
return timeOlson; return timeOlson;
} }
/**
* gets the Airports that are in this city.
* @return
*/
public ArrayList<Airport> getAirports(){ public ArrayList<Airport> getAirports(){
return airports; return airports;
} }
/**
* adds an airport that is in this city.
* @param airport
*/
public void addAirport(Airport airport){ public void addAirport(Airport airport){
airports.add(airport); airports.add(airport);
} }
/**
* adds multiple airports to this city.
* @param airports
*/
public void addAirport(ArrayList<Airport> airports){ public void addAirport(ArrayList<Airport> airports){
for (int i = 0; i < airports.size(); i++){ for (int i = 0; i < airports.size(); i++){
addAirport(airports.get(i)); addAirport(airports.get(i));
} }
} }
/**
* Deletes an Airport from this City.
* @param airport
*/
public void delAirport(Airport airport){ public void delAirport(Airport airport){
airports.remove(airport); airports.remove(airport);
} }
/**
* Deletes an Airport by Index from this City.
* @param index
*/
public void delAirport(int index) { public void delAirport(int index) {
airports.remove(index); airports.remove(index);
} }
@Override @Override
public String toString(){ public String toString(){
return this.name; return this.name + " has " + airports.size() + " Airports and is in "+timeOlson;
} }
} }

@ -7,20 +7,37 @@ public class Country {
private ArrayList<City> cities = new ArrayList<City>(); private ArrayList<City> cities = new ArrayList<City>();
private ArrayList<Airline> airlines = new ArrayList<Airline>(); private ArrayList<Airline> airlines = new ArrayList<Airline>();
private Position position; private Position position;
/**
* Contructor for Country.
* @param DST
* @param name
*/
public Country(String DST, String name){ public Country(String DST, String name){
this.DST = DST; this.DST = DST;
this.name = name; this.name = name;
} }
/**
* Sets the DST of the country.
* @param dST
*/
public void setDST(String dST) { public void setDST(String dST) {
DST = dST; DST = dST;
} }
/**
* Sets the name of the country.
* @param name
*/
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/**
* Set Airlines that are based in this country.
* @param airlines
*/
public void setAirlines(ArrayList<Airline> airlines) { public void setAirlines(ArrayList<Airline> airlines) {
this.airlines = new ArrayList<Airline>(); this.airlines = new ArrayList<Airline>();
for (int i = 0; i < airlines.size(); i ++) { for (int i = 0; i < airlines.size(); i ++) {
@ -28,36 +45,68 @@ public class Country {
} }
} }
/**
* Gets the DST of the Country.
* @return
*/
public String getDST(){ public String getDST(){
return this.DST; return this.DST;
} }
/**
* Gets the Name of the Country.
* @return
*/
public String getName(){ public String getName(){
return this.name; return this.name;
} }
/**
* gets the Airlines that belong in this Country.
* @return
*/
public ArrayList<Airline> getAirlines(){ public ArrayList<Airline> getAirlines(){
return airlines; return airlines;
} }
/**
* Adds an Airline that is based in this country.
* @param airline
*/
public void addAirline(Airline airline){ public void addAirline(Airline airline){
this.airlines.add(airline); this.airlines.add(airline);
} }
/**
* Adds multiple Airlines to this Country.
* @param airlines
*/
public void addAirline(ArrayList<Airline> airlines){ public void addAirline(ArrayList<Airline> airlines){
for (int i = 0; i < airlines.size(); i++){ for (int i = 0; i < airlines.size(); i++){
addAirline(airlines.get(i)); addAirline(airlines.get(i));
} }
} }
/**
* deletes an Airline based in this country.
* @param airline
*/
public void delAirline(Airline airline){ public void delAirline(Airline airline){
airlines.remove(airline); airlines.remove(airline);
} }
/**
* deletes an Airline in this country.
* @param index
*/
public void delAirline(int index){ public void delAirline(int index){
airlines.remove(index); airlines.remove(index);
} }
/**
* sets the cities of this country
* @param cities
*/
public void setCities(ArrayList<City> cities){ public void setCities(ArrayList<City> cities){
this.cities = new ArrayList<City>(); this.cities = new ArrayList<City>();
for (int i = 0; i < cities.size(); i++){ for (int i = 0; i < cities.size(); i++){
@ -65,32 +114,60 @@ public class Country {
} }
} }
/**
* adds a City to this country.
* @param city
*/
public void addCities(City city){ public void addCities(City city){
this.cities.add(city); this.cities.add(city);
} }
/**
* Add multiple Cities to this Country.
* @param cities
*/
public void addCities(ArrayList<City> cities){ public void addCities(ArrayList<City> cities){
for (int i = 0; i < cities.size(); i++){ for (int i = 0; i < cities.size(); i++){
this.cities.add(cities.get(i)); this.cities.add(cities.get(i));
} }
} }
/**
* Deletes a city for this country.
* @param city
*/
public void delCities(City city){ public void delCities(City city){
this.cities.remove(city); this.cities.remove(city);
} }
/**
* Deletes Cities in this Country
* @param index
*/
public void delCities(int index){ public void delCities(int index){
this.cities.remove(index); this.cities.remove(index);
} }
/**
* Gets the CIties in this Country.
* @return
*/
public ArrayList<City> getCities() { public ArrayList<City> getCities() {
return cities; return cities;
} }
/**
* gets the {@link Position}(double Latitude, double Longitude) of this Country.
* @return
*/
public Position getPosition() { public Position getPosition() {
return position; return position;
} }
/**
* sets the {@link Position} of the Country.
* @param position
*/
public void setPosition(Position position) { public void setPosition(Position position) {
this.position = position; this.position = position;
} }

@ -10,7 +10,7 @@ public class FlightPath {
final private RoutePath routePath = new RoutePath(); final private RoutePath routePath = new RoutePath();
/** /**
* * Constructor for this FLight Path from database
* @param ID id of the the flight path in the database * @param ID id of the the flight path in the database
* @param departureAirport Iata/FFA of the airport * @param departureAirport Iata/FFA of the airport
* @param arrivalAirport IATA/FFA of the airport * @param arrivalAirport IATA/FFA of the airport
@ -22,17 +22,30 @@ public class FlightPath {
this.flightPoints = new ArrayList<FlightPoint>(); this.flightPoints = new ArrayList<FlightPoint>();
} }
/**
* COnstructor for FlightPath from dataset add later the ID needs to be set from database.
* @param departureAirport
* @param arrivalAirport
*/
public FlightPath(String departureAirport, String arrivalAirport){ public FlightPath(String departureAirport, String arrivalAirport){
this.ID = -1; this.ID = -1;
this.departureAirport = departureAirport; this.departureAirport = departureAirport;
this.arrivalAirport = arrivalAirport; this.arrivalAirport = arrivalAirport;
this.flightPoints = new ArrayList<FlightPoint>(); this.flightPoints = new ArrayList<FlightPoint>();
} }
/**
* Gets the {@link FlightPoint} of this flight Path.
* @return
*/
public ArrayList<FlightPoint> getFlightPoints() { public ArrayList<FlightPoint> getFlightPoints() {
return flightPoints; return flightPoints;
} }
/**
* Sets the {@link FlightPoint} of this Flight Path.
* @param flightPoints
*/
public void setFlightPoints(ArrayList<FlightPoint> flightPoints) { public void setFlightPoints(ArrayList<FlightPoint> flightPoints) {
this.flightPoints = new ArrayList<FlightPoint>(); this.flightPoints = new ArrayList<FlightPoint>();
for (int i = 0; i < flightPoints.size(); i ++) { for (int i = 0; i < flightPoints.size(); i ++) {
@ -40,56 +53,112 @@ public class FlightPath {
} }
} }
/**
* Sets the {@link Airport} that the Flight Path leaves from.
* @param departureAirport
*/
public void setDepartureAirport(String departureAirport) { public void setDepartureAirport(String departureAirport) {
this.departureAirport = departureAirport; this.departureAirport = departureAirport;
} }
/**
* Sets the {@link Airport} that the Flight Path arrives at.
* @param arrivalAirport
*/
public void setArrivalAirport(String arrivalAirport) { public void setArrivalAirport(String arrivalAirport) {
this.arrivalAirport = arrivalAirport; this.arrivalAirport = arrivalAirport;
} }
/**
* Sets the ID that corresponds to the database for this flight path.
* Also the ID that corresponds to {@see FlightPoint} IndexID
* @param iD
*/
public void setID(int iD) { public void setID(int iD) {
ID = iD; ID = iD;
} }
/**
* gets the ID of the Flight Path.
* @return
*/
public int getID(){ public int getID(){
return ID; return ID;
} }
/**
* gets the {@link Airport} that the FLight Departs from.
* @return
*/
public String departsFrom(){ public String departsFrom(){
return departureAirport; return departureAirport;
} }
/**
* gets the {@link Airport} that the flight arrives at.
* @return
*/
public String arrivesAt(){ public String arrivesAt(){
return arrivalAirport; return arrivalAirport;
} }
/**
* Gets all the Points that the FLight passes
* {@link FlightPoint}
* @return
*/
public ArrayList<FlightPoint> getFlight(){ public ArrayList<FlightPoint> getFlight(){
return flightPoints; return flightPoints;
} }
/**
* Adds a {@link FlightPoint} to the Flight Path.
* @param flightPoint
*/
public void addFlightPoint(FlightPoint flightPoint){ public void addFlightPoint(FlightPoint flightPoint){
flightPoints.add(flightPoint); flightPoints.add(flightPoint);
} }
/**
* Adds a {@link FlightPoint} to the Flight Path at a specific point of the flight.
* @param flightPoint
* @param index
*/
public void addFlightPoint(FlightPoint flightPoint, int index){ public void addFlightPoint(FlightPoint flightPoint, int index){
flightPoints.add(index, flightPoint); flightPoints.add(index, flightPoint);
} }
/**
* deletes a point from the flight.
* @param flightPoint
*/
public void delFlightPoint(FlightPoint flightPoint){ public void delFlightPoint(FlightPoint flightPoint){
flightPoints.remove(flightPoint); flightPoints.remove(flightPoint);
} }
/**
* delets a point from the flight at a specific index.
* @param index
*/
public void delFlightPoint(int index){ public void delFlightPoint(int index){
flightPoints.remove(index); flightPoints.remove(index);
} }
/**
* Adds multiple {@link FlightPoint} to the FlightPath.
* @param flightPoints
*/
public void addFlightPoint(ArrayList<FlightPoint> flightPoints){ public void addFlightPoint(ArrayList<FlightPoint> flightPoints){
for (int i = 0; i < flightPoints.size(); i ++){ for (int i = 0; i < flightPoints.size(); i ++){
this.flightPoints.add(flightPoints.get(i)); this.flightPoints.add(flightPoints.get(i));
} }
} }
/**
* Gets the {@link RoutePath} that the FlightPath traverses.
* Also see {@see seng202.group9.Map.Map}
* @return
*/
public RoutePath getRoutePath(){ public RoutePath getRoutePath(){
if (routePath.getRoute().size() == 0){ if (routePath.getRoute().size() == 0){
for (FlightPoint point: flightPoints){ for (FlightPoint point: flightPoints){

@ -15,6 +15,14 @@ public class FlightPoint {
private double latitude; private double latitude;
private double longitude; private double longitude;
/**
* Constructor for FLight POint before set by the database.
* @param type
* @param name
* @param altitude
* @param latitude
* @param longitude
*/
public FlightPoint(String type, String name, double altitude, double latitude, double longitude){ public FlightPoint(String type, String name, double altitude, double latitude, double longitude){
//extra calculations will have to be used to find heading, legdistance and total distance. If necessary //extra calculations will have to be used to find heading, legdistance and total distance. If necessary
//Type 1 file the file the lecturers gave us //Type 1 file the file the lecturers gave us
@ -33,6 +41,20 @@ public class FlightPoint {
this.longitude = longitude; this.longitude = longitude;
} }
/**
* Constructor when getting points from the database.
* @param name Name for the point.
* @param ID Unique ID from Database.
* @param indexID FOreighn key for {@link FlightPath}.
* @param type
* @param via
* @param heading
* @param altitude
* @param legDistance
* @param totalDistance
* @param latitude
* @param longitude
*/
public FlightPoint(String name, int ID, int indexID, String type, String via, public FlightPoint(String name, int ID, int indexID, String type, String via,
int heading, double altitude, double legDistance, double totalDistance, int heading, double altitude, double legDistance, double totalDistance,
double latitude, double longitude){ double latitude, double longitude){
@ -49,6 +71,11 @@ public class FlightPoint {
this.longitude = longitude; this.longitude = longitude;
} }
/**
* get the Path ID
* @return
* @throws DataException
*/
public int getIndexID() throws DataException { public int getIndexID() throws DataException {
if (this.ID == -1){ if (this.ID == -1){
throw new DataException("ID not set."); throw new DataException("ID not set.");
@ -57,54 +84,107 @@ public class FlightPoint {
} }
} }
/**
* sets the Path ID
* @param indexID
*/
public void setIndexID(int indexID) { public void setIndexID(int indexID) {
this.indexID = indexID; this.indexID = indexID;
} }
/**
* sets the name of the path.
* @param name
*/
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/**
* sets the Unique Database ID of the Path
* @param iD
*/
public void setID(int iD) { public void setID(int iD) {
ID = iD; ID = iD;
} }
/**
* Sets the type of the Point.
* @param type
*/
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
/**
* set the VIA of the Point.
* @param via
*/
public void setVia(String via) { public void setVia(String via) {
this.via = via; this.via = via;
} }
/**
* Sets bearing the flight is heading.
* @param heading
*/
public void setHeading(int heading) { public void setHeading(int heading) {
this.heading = heading; this.heading = heading;
} }
/**
* sets the altitude of the flight at this point.
* @param altitude
*/
public void setAltitude(double altitude) { public void setAltitude(double altitude) {
this.altitude = altitude; this.altitude = altitude;
} }
/**
* sets the distance this flight takes before the next point.
* @param legDistance
*/
public void setLegDistance(double legDistance) { public void setLegDistance(double legDistance) {
this.legDistance = legDistance; this.legDistance = legDistance;
} }
/**
* sets total distance travelled at this point.
* @param totalDistance
*/
public void setTotalDistance(double totalDistance) { public void setTotalDistance(double totalDistance) {
this.totalDistance = totalDistance; this.totalDistance = totalDistance;
} }
/**
* sets the latitude at this point.
* @param latitude
*/
public void setLatitude(double latitude) { public void setLatitude(double latitude) {
this.latitude = latitude; this.latitude = latitude;
} }
/**
* Sets the Longitude at this point.
* @param longitude
*/
public void setLongitude(double longitude) { public void setLongitude(double longitude) {
this.longitude = longitude; this.longitude = longitude;
} }
/**
* gets the name of this point.
* @return
*/
public String getName(){ public String getName(){
return name; return name;
} }
/**
* gets the UNIQUE ID at this point.
* @return
* @throws DataException
*/
public int getID() throws DataException { public int getID() throws DataException {
if (this.ID == -1){ if (this.ID == -1){
throw new DataException("ID not set."); throw new DataException("ID not set.");
@ -112,39 +192,75 @@ public class FlightPoint {
return ID; return ID;
} }
} }
/**
* gets the Path Index ID at this point.
* @return
*/
public int getIndex(){ public int getIndex(){
return indexID; return indexID;
} }
/**
* gets the type of this point.
* @return
*/
public String getType(){ public String getType(){
return type; return type;
} }
/**
* gets where the plane is via at this point.
* @return
*/
public String getVia(){ public String getVia(){
return via; return via;
} }
/**
* gets the Heading bearing at this point
* @return
*/
public int getHeading(){ public int getHeading(){
return heading; return heading;
} }
/**
* gets the altitude at this poitn.
* @return
*/
public double getAltitude(){ public double getAltitude(){
return altitude; return altitude;
} }
/**
* gets the leg distance at this point.
* @return
*/
public double getLegDistance(){ public double getLegDistance(){
return legDistance; return legDistance;
} }
/**
* gets total distance travelled by this flight so far.
* @return
*/
public double getTotalDistance(){ public double getTotalDistance(){
return totalDistance; return totalDistance;
} }
/**
* gets longitude of this point.
* @return
*/
public double getLongitude(){ public double getLongitude(){
return longitude; return longitude;
} }
/**
* gets the latitude of this point.
* @return
*/
public double getLatitude(){ public double getLatitude(){
return latitude; return latitude;
} }

@ -121,7 +121,12 @@ public class Route {
return ID; return ID;
} }
} }
//JavaDoc needed
/**
* Gets this ID of the Airline.
* @return
* @throws DataException
*/
public int getAirlineID() throws DataException { public int getAirlineID() throws DataException {
if (this.getAirline() != null) { if (this.getAirline() != null) {
return this.getAirline().getID(); return this.getAirline().getID();
@ -130,6 +135,11 @@ public class Route {
} }
} }
/**
* Gets the ID of the Airport that the Route leaves from.
* @return
* @throws DataException
*/
public int getSourceID() throws DataException { public int getSourceID() throws DataException {
if (this.getSourceAirport() != null) { if (this.getSourceAirport() != null) {
return this.getSourceAirport().getID(); return this.getSourceAirport().getID();
@ -138,6 +148,11 @@ public class Route {
} }
} }
/**
* gets the destination ID of the Airport the Route is arriving at.
* @return
* @throws DataException
*/
public int getDestID() throws DataException { public int getDestID() throws DataException {
if (this.getDestinationAirport() != null) { if (this.getDestinationAirport() != null) {
return this.getDestinationAirport().getID(); return this.getDestinationAirport().getID();
@ -248,6 +263,10 @@ public class Route {
} }
} }
/**
* gets the RoutePath to be passed into {@link seng202.group9.Map.Map}.
* @return
*/
public RoutePath getRoutePath(){ public RoutePath getRoutePath(){
if (routePath == null) { if (routePath == null) {
routePath = new RoutePath( routePath = new RoutePath(
@ -258,6 +277,10 @@ public class Route {
return routePath; return routePath;
} }
/**
* What to print if printed as a string.
* @return
*/
@Override @Override
public String toString(){ public String toString(){

@ -10,22 +10,41 @@ import java.util.Collections;
public class RoutePath { public class RoutePath {
private ArrayList<Position> route = new ArrayList<Position>(); private ArrayList<Position> route = new ArrayList<Position>();
/**
* Route Path constructor when the user knows the points.
* @param points
*/
public RoutePath(Position ...points) { public RoutePath(Position ...points) {
Collections.addAll(route, points); Collections.addAll(route, points);
} }
/**
* Route Path constructor when the user doesn't know the points.
*/
public RoutePath(){ public RoutePath(){
} }
/**
* adds a {@link Position} to the RoutePath.
* @param position
*/
public void addPosition(Position position){ public void addPosition(Position position){
route.add(position); route.add(position);
} }
/**
* Gets the RoutePath positions.
* @return
*/
public ArrayList<Position> getRoute() { public ArrayList<Position> getRoute() {
return route; return route;
} }
/**
* Converts the RoutePath to an Array in JSON which can then be passed to the Map to display.
* @return
*/
public String toJSONArray() { public String toJSONArray() {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("["); stringBuilder.append("[");

Loading…
Cancel
Save