|
|
|
@ -8,19 +8,20 @@ import seng202.group9.Controller.DataException;
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class Route {
|
|
|
|
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 int stops;
|
|
|
|
private String codeShare;
|
|
|
|
private String codeShare;
|
|
|
|
private String equipment;
|
|
|
|
private String equipment;
|
|
|
|
private String airline;
|
|
|
|
private String airlineName;
|
|
|
|
private String departureAirport;
|
|
|
|
private String departureAirport;
|
|
|
|
private String arrivalAirport;
|
|
|
|
private String arrivalAirport;
|
|
|
|
private Airport sourceAirport;
|
|
|
|
private Airport sourceAirport;
|
|
|
|
private Airport destinationAirport;
|
|
|
|
private Airport destinationAirport;
|
|
|
|
|
|
|
|
private Airline airline = null;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Constructor for pulling from database
|
|
|
|
* Constructor for pulling from database
|
|
|
|
* @param airline
|
|
|
|
* @param airlineName
|
|
|
|
* @param ID
|
|
|
|
* @param ID
|
|
|
|
* @param departureAirport
|
|
|
|
* @param departureAirport
|
|
|
|
* @param arrivalAirport
|
|
|
|
* @param arrivalAirport
|
|
|
|
@ -28,26 +29,26 @@ public class Route {
|
|
|
|
* @param stops
|
|
|
|
* @param stops
|
|
|
|
* @param equipment
|
|
|
|
* @param equipment
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Route(int ID, String airline, String departureAirport, String arrivalAirport,
|
|
|
|
public Route(int ID, String airlineName, String departureAirport, String arrivalAirport,
|
|
|
|
String codeShare, int stops, String equipment){
|
|
|
|
String codeShare, int stops, String equipment){
|
|
|
|
this.ID = ID;
|
|
|
|
this.ID = ID;
|
|
|
|
this.stops = stops;
|
|
|
|
this.stops = stops;
|
|
|
|
this.codeShare = codeShare;
|
|
|
|
this.codeShare = codeShare;
|
|
|
|
this.equipment = equipment;
|
|
|
|
this.equipment = equipment;
|
|
|
|
this.airline = airline;
|
|
|
|
this.airlineName = airlineName;
|
|
|
|
this.departureAirport = departureAirport;
|
|
|
|
this.departureAirport = departureAirport;
|
|
|
|
this.arrivalAirport = arrivalAirport;
|
|
|
|
this.arrivalAirport = arrivalAirport;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Constructor for adding
|
|
|
|
* Constructor for adding
|
|
|
|
* @param airline
|
|
|
|
* @param airlineName
|
|
|
|
* @param departureAirport
|
|
|
|
* @param departureAirport
|
|
|
|
* @param arrivalAirport
|
|
|
|
* @param arrivalAirport
|
|
|
|
* @param codeShare
|
|
|
|
* @param codeShare
|
|
|
|
* @param stops
|
|
|
|
* @param stops
|
|
|
|
* @param equipment
|
|
|
|
* @param equipment
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Route(String airline, String departureAirport, String arrivalAirport,
|
|
|
|
public Route(String airlineName, String departureAirport, String arrivalAirport,
|
|
|
|
String codeShare, int stops, String equipment){
|
|
|
|
String codeShare, int stops, String equipment){
|
|
|
|
//remember to set the id manually later after adding it to the database and grab
|
|
|
|
//remember to set the id manually later after adding it to the database and grab
|
|
|
|
//the new id value of the route.
|
|
|
|
//the new id value of the route.
|
|
|
|
@ -55,7 +56,7 @@ public class Route {
|
|
|
|
this.stops = stops;
|
|
|
|
this.stops = stops;
|
|
|
|
this.codeShare = codeShare;
|
|
|
|
this.codeShare = codeShare;
|
|
|
|
this.equipment = equipment;
|
|
|
|
this.equipment = equipment;
|
|
|
|
this.airline = airline;
|
|
|
|
this.airlineName = airlineName;
|
|
|
|
this.departureAirport = departureAirport;
|
|
|
|
this.departureAirport = departureAirport;
|
|
|
|
this.arrivalAirport = arrivalAirport;
|
|
|
|
this.arrivalAirport = arrivalAirport;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -102,11 +103,11 @@ public class Route {
|
|
|
|
this.equipment = equipment;
|
|
|
|
this.equipment = equipment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* sets airline that flies this route
|
|
|
|
* sets airlineName that flies this route
|
|
|
|
* @param airline
|
|
|
|
* @param airlineName
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void setAirline(String airline) {
|
|
|
|
public void setAirlineName(String airlineName) {
|
|
|
|
this.airline = airline;
|
|
|
|
this.airlineName = airlineName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* returns the id of this route
|
|
|
|
* returns the id of this route
|
|
|
|
@ -141,11 +142,11 @@ public class Route {
|
|
|
|
return equipment;
|
|
|
|
return equipment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* returns the airline that flies this route
|
|
|
|
* returns the airlineName that flies this route
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public String getAirline(){
|
|
|
|
public String getAirlineName(){
|
|
|
|
return airline;
|
|
|
|
return airlineName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* returns the source airport of this route
|
|
|
|
* returns the source airport of this route
|
|
|
|
@ -194,12 +195,27 @@ public class Route {
|
|
|
|
this.sourceAirport = 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
|
|
|
|
* Checks is passed route is a duplicate of the current one if so it throws an DataException
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void hasDuplicate(Route route) throws DataException{
|
|
|
|
public void hasDuplicate(Route route) throws DataException{
|
|
|
|
//routeAirline + routeSourceAirport + routeArrvAirport + routeCodeShare + routeStops + routeEquip
|
|
|
|
//routeAirline + routeSourceAirport + routeArrvAirport + routeCodeShare + routeStops + routeEquip
|
|
|
|
if (route.getAirline().equals(this.airline) && route.departsFrom().equals(this.departureAirport)
|
|
|
|
if (route.getAirlineName().equals(this.airlineName) && route.departsFrom().equals(this.departureAirport)
|
|
|
|
&& route.arrivesAt().equals(this.arrivalAirport) && route.getCode().equals(this.codeShare)
|
|
|
|
&& route.arrivesAt().equals(this.arrivalAirport) && route.getCode().equals(this.codeShare)
|
|
|
|
&& route.getStops() == this.stops && route.getEquipment().equals(this.equipment)){
|
|
|
|
&& route.getStops() == this.stops && route.getEquipment().equals(this.equipment)){
|
|
|
|
throw new DataException("This Route already exists.");
|
|
|
|
throw new DataException("This Route already exists.");
|
|
|
|
@ -208,7 +224,7 @@ public class Route {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public String toString(){
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|