Add Singular Route Adding Function
This commit is contained in:
@@ -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.");
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -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(){
|
||||
|
||||
|
||||
Reference in New Issue
Block a user