Add Singular Route Adding Function

This commit is contained in:
YaFedImYaEatIm
2016-09-14 22:58:04 +12:00
parent 66ee9ced2d
commit c7f033283d
4 changed files with 98 additions and 7 deletions
@@ -309,10 +309,10 @@ public class Airport {
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.");
throw new DataException("Airport IATA/FFA already Exists, Please Choose Another.");
}
if (!airport.getICAO().equals("") && airport.getICAO().equals(this.name)){
throw new DataException("Airport Name already Exists, Please Choose Another.");
throw new DataException("Airport ICAO already Exists, Please Choose Another.");
}
}
/**
+12 -1
View File
@@ -158,7 +158,18 @@ public class Route {
public String arrivesAt(){
return arrivalAirport;
}
/**
* Checks is passed route is a duplicate of the current one if so it throws an DataException
*/
public void hasDuplicate(Route route) throws DataException{
//routeAirline + routeSourceAirport + routeArrvAirport + routeCodeShare + routeStops + routeEquip
if (route.getAirline().equals(this.airline) && route.departsFrom().equals(this.departureAirport)
&& route.arrivesAt().equals(this.arrivalAirport) && route.getCode().equals(this.codeShare)
&& route.getStops() == this.stops && route.getEquipment().equals(this.equipment)){
throw new DataException("This Route already exists.");
}
}
@Override
public String toString(){