Added singular Airport adding

This commit is contained in:
YaFedImYaEatIm
2016-09-14 11:51:39 +12:00
parent 4418bc6824
commit d84346de60
5 changed files with 144 additions and 7 deletions
@@ -205,7 +205,7 @@ public class Airline {
}
/**
* Function Overload of addRoutes this allow the adding of a list to route
* @param routes
* @param routesToAdd array list of routes to add routes
*/
public void addRoutes(ArrayList<Route> routesToAdd){
for (int i = 0; i < routesToAdd.size(); i ++){
@@ -235,19 +235,19 @@ public class Airline {
* @return
*/
public void hasDuplicate(Airline airline) throws DataException{
if (this.name == airline.getName()){
if (this.name.equals(airline.getName())){
throw new DataException("This Airline Name already Exists, Please Choose Another.");
}
if (this.IATA != "" && this.IATA == airline.getIATA()){
if (!this.IATA.equals("") && this.IATA.equals(airline.getIATA())){
throw new DataException("This IATA Code already Exists, Please Choose Another.");
}
if (this.ICAO != "" && this.ICAO == airline.getICAO()){
if (!this.ICAO.equals("") && this.ICAO.equals(airline.getICAO())){
throw new DataException("This ICAO Code already Exists, Please Choose Another.");
}
if (this.alias != "" && this.alias == airline.getAlias()){
if (!this.alias.equals("") && this.alias.equals(airline.getAlias())){
throw new DataException("This Alias already Exists, Please Choose Another.");
}
if (this.callSign != "" && this.callSign == airline.getCallSign()){
if (!this.callSign.equals("") && this.callSign.equals(airline.getCallSign())){
throw new DataException("This Callsign already Exists, Please Choose Another.");
}
}
@@ -304,6 +304,17 @@ public class Airport {
distance = 6371 * c;
return distance;
}
public void hasDuplicate(Airport airport) throws DataException{
if (!airport.getName().equals("") && airport.getName().equals(this.name)){
throw new DataException("Airport Name already Exists, Please Choose Another.");
}
if (!airport.getIATA_FFA().equals("") && airport.getIATA_FFA().equals(this.name)){
throw new DataException("Airport Name already Exists, Please Choose Another.");
}
if (!airport.getICAO().equals("") && airport.getICAO().equals(this.name)){
throw new DataException("Airport Name already Exists, Please Choose Another.");
}
}
/**
* Information of the airport returned in String format.
*/