Refactored some variables

This commit is contained in:
YaFedImYaEatIm
2016-09-15 17:01:42 +12:00
parent 76da24c06e
commit 58c2c6a839
10 changed files with 142 additions and 57 deletions
+29 -12
View File
@@ -17,9 +17,10 @@ public class Airline {
private String alias;
private String callSign;
private String active;
private String country;
private String countryName;
private ArrayList<Route> routes;
private Country country = null;
/**
* Constructor
*
@@ -29,10 +30,10 @@ public class Airline {
* @param IATA
* @param ICAO
* @param callSign
* @param country
* @param countryName
* @param active
*/
public Airline(int ID, String name, String alias, String IATA, String ICAO, String callSign, String country, String active){
public Airline(int ID, String name, String alias, String IATA, String ICAO, String callSign, String countryName, String active){
this.ID = ID;
this.IATA = IATA;
this.ICAO = ICAO;
@@ -40,12 +41,12 @@ public class Airline {
this.alias = alias;
this.callSign = callSign;
this.active = active;
this.country = country;
this.countryName = countryName;
this.routes = new ArrayList<Route>();
}
public Airline(String name, String alias, String IATA, String ICAO, String callSign, String country, String active){
public Airline(String name, String alias, String IATA, String ICAO, String callSign, String countryName, String active){
this.ID = -1;
this.IATA = IATA;
this.ICAO = ICAO;
@@ -53,7 +54,7 @@ public class Airline {
this.alias = alias;
this.callSign = callSign;
this.active = active;
this.country = country;
this.countryName = countryName;
this.routes = new ArrayList<Route>();
}
/**
@@ -109,10 +110,10 @@ public class Airline {
}
/**
* Changes Country the Airline belongs to
* @param country
* @param countryName
*/
public void setCountry(String country) {
this.country = country;
public void setCountryName(String countryName) {
this.countryName = countryName;
}
/**
* Sets routes to the airline
@@ -181,12 +182,28 @@ public class Airline {
return active;
}
/**
* get the country the airline belongs to
* get the countryName the airline belongs to
* @return
*/
public String getCountry(){
public String getCountryName(){
return countryName;
}
/**
* gets the Country class that this airline belongs to
* @return
*/
public Country getCountry() {
return country;
}
/**
* sets the country class this airline belongs to
* @param country
*/
public void setCountry(Country country) {
this.country = country;
}
/**
* get routes the airline flies
* @return
+56 -21
View File
@@ -16,8 +16,10 @@ public class Airport {
private double altitude;
private double longitude;
private double latitude;
private String city;
private String country;
private String cityName;
private City city;
private String countryName;
private Country country;
private ArrayList<Route> departureRoutes = new ArrayList<Route>();
private ArrayList<Route> arrivalRoutes = new ArrayList<Route>();
@@ -25,14 +27,15 @@ public class Airport {
* Constructor
* @param ID from the database
* @param name Name of the airport
* @param city city of the airport
* @param cityName cityName of the airport
* @param countryName name of Country the airport belongs to
* @param IATA_FFA
* @param ICAO
* @param altitude
* @param longitude
* @param latitude
*/
public Airport(int ID, String name, String city, String country, String IATA_FFA, String ICAO, double latitude, double longitude
public Airport(int ID, String name, String cityName, String countryName, String IATA_FFA, String ICAO, double latitude, double longitude
, double altitude){
this.ID = ID;
this.name = name;
@@ -41,19 +44,19 @@ public class Airport {
this.altitude = altitude;
this.longitude = longitude;
this.latitude = latitude;
this.city = city;
this.country = country;
this.cityName = cityName;
this.countryName = countryName;
}
/**
* Secondary Constructor the ID needs to be set after.
* @param city City of airport
* @param cityName City of airport
* @param IATA_FFA
* @param ICAO
* @param altitude
* @param longitude
* @param latitude
*/
public Airport(String name, String city, String country, String IATA_FFA, String ICAO, double latitude, double longitude
public Airport(String name, String cityName, String countryName, String IATA_FFA, String ICAO, double latitude, double longitude
, double altitude){
this.ID = -1;
this.name = name;
@@ -62,8 +65,8 @@ public class Airport {
this.altitude = altitude;
this.longitude = longitude;
this.latitude = latitude;
this.city = city;
this.country = country;
this.cityName = cityName;
this.countryName = countryName;
}
/**
* returns the IATA/FFA code
@@ -127,11 +130,11 @@ public class Airport {
this.longitude = longitude;
}
/**
* sets the city of the airport (which city it is in)
* @param city
* sets the cityName of the airport (which cityName it is in)
* @param cityName
*/
public void setCity(String city) {
this.city = city;
public void setCityName(String cityName) {
this.cityName = cityName;
}
/**
* set the routes that depart from it
@@ -145,12 +148,12 @@ public class Airport {
}
}
public String getCountry() {
return country;
public String getCountryName() {
return countryName;
}
public void setCountry(String country) {
this.country = country;
public void setCountryName(String countryName) {
this.countryName = countryName;
}
/**
@@ -220,12 +223,44 @@ public class Airport {
return latitude;
}
/**
* gets the city the airport is located in
* gets the cityName the airport is located in
* @return City of Airport
*/
public String getCity(){
public String getCityName(){
return cityName;
}
/**
* gets the city class asssociated wit hthis airport
* @return
*/
public City getCity() {
return city;
}
/**
* sets the city class associated with this airport
* @param city
*/
public void setCity(City city) {
this.city = city;
}
/**
* get country class associated with this airport
* @return
*/
public Country getCountry() {
return country;
}
/**
* set country class associated with this airport
* @param country
*/
public void setCountry(Country country) {
this.country = country;
}
/**
* gets the routes that depart from this airport
* @return Routes Departing from Airport
@@ -321,7 +356,7 @@ public class Airport {
@Override
public String toString(){
return this.city+" 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
+ ").\n It has "+this.departureRoutes.size()+" departing routes and "+this.arrivalRoutes.size()+" arriving routes.";
}
}
@@ -15,6 +15,9 @@ public class Route {
private String airline;
private String departureAirport;
private String arrivalAirport;
private Airport sourceAirport;
private Airport destinationAirport;
/**
* Constructor for pulling from database
* @param airline
@@ -159,6 +162,38 @@ public class Route {
return arrivalAirport;
}
/**
* get Airport class that is bound with the destination of the airport
* @return
*/
public Airport getDestinationAirport() {
return destinationAirport;
}
/**
* set Airport class that is bound with the destination of the airport
* @param destinationAirport
*/
public void setDestinationAirport(Airport destinationAirport) {
this.destinationAirport = destinationAirport;
}
/**
* get Airport class that is bound with the source airport
* @return
*/
public Airport getSourceAirport() {
return sourceAirport;
}
/**
* set Airport class that is bound with the source airport
* @param sourceAirport
*/
public void setSourceAirport(Airport sourceAirport) {
this.sourceAirport = sourceAirport;
}
/**
* Checks is passed route is a duplicate of the current one if so it throws an DataException
*/