Finished Create Link() establishment
This commit is contained in:
@@ -8,19 +8,20 @@ import seng202.group9.Controller.DataException;
|
||||
*
|
||||
*/
|
||||
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 String codeShare;
|
||||
private String equipment;
|
||||
private String airline;
|
||||
private String airlineName;
|
||||
private String departureAirport;
|
||||
private String arrivalAirport;
|
||||
private Airport sourceAirport;
|
||||
private Airport destinationAirport;
|
||||
private Airline airline = null;
|
||||
|
||||
/**
|
||||
* Constructor for pulling from database
|
||||
* @param airline
|
||||
* @param airlineName
|
||||
* @param ID
|
||||
* @param departureAirport
|
||||
* @param arrivalAirport
|
||||
@@ -28,34 +29,34 @@ public class Route {
|
||||
* @param stops
|
||||
* @param equipment
|
||||
*/
|
||||
public Route(int ID, String airline, String departureAirport, String arrivalAirport,
|
||||
String codeShare, int stops, String equipment){
|
||||
public Route(int ID, String airlineName, String departureAirport, String arrivalAirport,
|
||||
String codeShare, int stops, String equipment){
|
||||
this.ID = ID;
|
||||
this.stops = stops;
|
||||
this.codeShare = codeShare;
|
||||
this.equipment = equipment;
|
||||
this.airline = airline;
|
||||
this.airlineName = airlineName;
|
||||
this.departureAirport = departureAirport;
|
||||
this.arrivalAirport = arrivalAirport;
|
||||
}
|
||||
/**
|
||||
* Constructor for adding
|
||||
* @param airline
|
||||
* @param airlineName
|
||||
* @param departureAirport
|
||||
* @param arrivalAirport
|
||||
* @param codeShare
|
||||
* @param stops
|
||||
* @param equipment
|
||||
*/
|
||||
public Route(String airline, String departureAirport, String arrivalAirport,
|
||||
String codeShare, int stops, String equipment){
|
||||
public Route(String airlineName, String departureAirport, String arrivalAirport,
|
||||
String codeShare, int stops, String equipment){
|
||||
//remember to set the id manually later after adding it to the database and grab
|
||||
//the new id value of the route.
|
||||
this.ID = -1;
|
||||
this.stops = stops;
|
||||
this.codeShare = codeShare;
|
||||
this.equipment = equipment;
|
||||
this.airline = airline;
|
||||
this.airlineName = airlineName;
|
||||
this.departureAirport = departureAirport;
|
||||
this.arrivalAirport = arrivalAirport;
|
||||
}
|
||||
@@ -102,11 +103,11 @@ public class Route {
|
||||
this.equipment = equipment;
|
||||
}
|
||||
/**
|
||||
* sets airline that flies this route
|
||||
* @param airline
|
||||
* sets airlineName that flies this route
|
||||
* @param airlineName
|
||||
*/
|
||||
public void setAirline(String airline) {
|
||||
this.airline = airline;
|
||||
public void setAirlineName(String airlineName) {
|
||||
this.airlineName = airlineName;
|
||||
}
|
||||
/**
|
||||
* returns the id of this route
|
||||
@@ -141,11 +142,11 @@ public class Route {
|
||||
return equipment;
|
||||
}
|
||||
/**
|
||||
* returns the airline that flies this route
|
||||
* returns the airlineName that flies this route
|
||||
* @return
|
||||
*/
|
||||
public String getAirline(){
|
||||
return airline;
|
||||
public String getAirlineName(){
|
||||
return airlineName;
|
||||
}
|
||||
/**
|
||||
* returns the source airport of this route
|
||||
@@ -194,12 +195,27 @@ public class Route {
|
||||
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
|
||||
*/
|
||||
public void hasDuplicate(Route route) throws DataException{
|
||||
//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.getStops() == this.stops && route.getEquipment().equals(this.equipment)){
|
||||
throw new DataException("This Route already exists.");
|
||||
@@ -208,7 +224,7 @@ public class Route {
|
||||
@Override
|
||||
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";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user