Merged CreateLinks Branch which allowed CreateLinks() function to work along with new Import Messages

This commit is contained in:
YaFedImYaEatIm
2016-09-16 00:13:55 +12:00
13 changed files with 222 additions and 88 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.";
}
}
+69 -18
View File
@@ -8,16 +8,20 @@ import seng202.group9.Controller.DataException;
*
*/
public class Route {
private int ID;//this ID is the route id not the airline or airports.
private int ID;//this ID is the route id not the airlineName or airports.
private int stops;
private String codeShare;
private String equipment;
private String airline;
private String airlineName;
private String departureAirport;
private String arrivalAirport;
private Airport sourceAirport;
private Airport destinationAirport;
private Airline airline = null;
/**
* Constructor for pulling from database
* @param airline
* @param airlineName
* @param ID
* @param departureAirport
* @param arrivalAirport
@@ -25,34 +29,34 @@ public class Route {
* @param stops
* @param equipment
*/
public Route(int ID, String airline, String departureAirport, String arrivalAirport,
String codeShare, int stops, String equipment){
public Route(int ID, String airlineName, String departureAirport, String arrivalAirport,
String codeShare, int stops, String equipment){
this.ID = ID;
this.stops = stops;
this.codeShare = codeShare;
this.equipment = equipment;
this.airline = airline;
this.airlineName = airlineName;
this.departureAirport = departureAirport;
this.arrivalAirport = arrivalAirport;
}
/**
* Constructor for adding
* @param airline
* @param airlineName
* @param departureAirport
* @param arrivalAirport
* @param codeShare
* @param stops
* @param equipment
*/
public Route(String airline, String departureAirport, String arrivalAirport,
String codeShare, int stops, String equipment){
public Route(String airlineName, String departureAirport, String arrivalAirport,
String codeShare, int stops, String equipment){
//remember to set the id manually later after adding it to the database and grab
//the new id value of the route.
this.ID = -1;
this.stops = stops;
this.codeShare = codeShare;
this.equipment = equipment;
this.airline = airline;
this.airlineName = airlineName;
this.departureAirport = departureAirport;
this.arrivalAirport = arrivalAirport;
}
@@ -99,11 +103,11 @@ public class Route {
this.equipment = equipment;
}
/**
* sets airline that flies this route
* @param airline
* sets airlineName that flies this route
* @param airlineName
*/
public void setAirline(String airline) {
this.airline = airline;
public void setAirlineName(String airlineName) {
this.airlineName = airlineName;
}
/**
* returns the id of this route
@@ -138,11 +142,11 @@ public class Route {
return equipment;
}
/**
* returns the airline that flies this route
* returns the airlineName that flies this route
* @return
*/
public String getAirline(){
return airline;
public String getAirlineName(){
return airlineName;
}
/**
* returns the source airport of this route
@@ -159,6 +163,53 @@ 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;
}
/**
* gets Airline clas that is bound to the Airline that flights this route.
* @return
*/
public Airline getAirline() {
return airline;
}
/**
* sets Airline clas that is bound to the Airline that flights this route.
* @return
*/
public void setAirline(Airline airline) {
this.airline = airline;
}
/**
* Checks is passed route is a duplicate of the current one if so it throws an DataException
*/
@@ -173,7 +224,7 @@ public class Route {
@Override
public String toString(){
return airline+" flies from "+departureAirport+" to "+arrivalAirport+" on a "+equipment +" stopping "+stops+" amount of times";
return airlineName +" flies from "+departureAirport+" to "+arrivalAirport+" on a "+equipment +" stopping "+stops+" amount of times";
}
}