Made Add Airline FUnction

This commit is contained in:
YaFedImYaEatIm
2016-09-14 10:25:58 +12:00
parent dac4146f33
commit a89e5f7b95
3 changed files with 88 additions and 12 deletions
@@ -228,6 +228,29 @@ public class Airline {
public void delRoutes(int index){
routes.remove(index);
}
/**
* checks if the airline has a duplicate unique entry to another. Used for validating
* @param airline
* @return
*/
public void hasDuplicate(Airline airline) throws DataException{
if (this.name == airline.getName()){
throw new DataException("This Airline Name already Exists, Please Choose Another.");
}
if (this.IATA != "" && this.IATA == airline.getIATA()){
throw new DataException("This IATA Code already Exists, Please Choose Another.");
}
if (this.ICAO != "" && this.ICAO == airline.getICAO()){
throw new DataException("This ICAO Code already Exists, Please Choose Another.");
}
if (this.alias != "" && this.alias == airline.getAlias()){
throw new DataException("This Alias already Exists, Please Choose Another.");
}
if (this.callSign != "" && this.callSign == airline.getCallSign()){
throw new DataException("This Callsign already Exists, Please Choose Another.");
}
}
/**
* returns the name of the airline when concatenated to a string.
*/