Merged into master branch
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -289,6 +289,21 @@ public class Airport {
|
||||
public void delArrivalRoutes(int index){
|
||||
arrivalRoutes.remove(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the distance between this airport and another airport in kilometers.
|
||||
* @param airport
|
||||
* @return
|
||||
*/
|
||||
public double calculateDistance(Airport airport){
|
||||
double distance = 0;
|
||||
double dLong = this.longitude - airport.getLatitude();
|
||||
double dLat = this.latitude - airport.getLatitude();
|
||||
double a = Math.pow((Math.sin(dLat/2)), 2) + Math.cos(this.latitude) * Math.cos(airport.getLatitude()) * Math.pow(Math.sin(dLong/2), 2);
|
||||
double c = a * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
|
||||
distance = 6371 * c;
|
||||
return distance;
|
||||
}
|
||||
/**
|
||||
* Information of the airport returned in String format.
|
||||
*/
|
||||
|
||||
@@ -20,6 +20,13 @@ public class FlightPath {
|
||||
this.arrivalAirport = arrivalAirport;
|
||||
this.flightPoints = new ArrayList<FlightPoint>();
|
||||
}
|
||||
|
||||
public FlightPath(String departureAirport, String arrivalAirport){
|
||||
this.ID = -1;
|
||||
this.departureAirport = departureAirport;
|
||||
this.arrivalAirport = arrivalAirport;
|
||||
this.flightPoints = new ArrayList<FlightPoint>();
|
||||
}
|
||||
|
||||
public ArrayList<FlightPoint> getFlightPoints() {
|
||||
return flightPoints;
|
||||
|
||||
@@ -15,14 +15,14 @@ public class FlightPoint {
|
||||
private double latitude;
|
||||
private double longitude;
|
||||
|
||||
public FlightPoint(String type, String via, double altitude, double latitude, double longitude){
|
||||
public FlightPoint(String type, String name, double altitude, double latitude, double longitude){
|
||||
//extra calculations will have to be used to find heading, legdistance and total distance. If necessary
|
||||
//Type 1 file the file the lecturers gave us
|
||||
this.name = "";
|
||||
this.name = name;
|
||||
this.ID = -1;
|
||||
this.indexID = -1;
|
||||
this.type = type;
|
||||
this.via = via;
|
||||
this.via = "";
|
||||
this.heading = 0;
|
||||
this.altitude = altitude;
|
||||
this.legDistance = 0.0;
|
||||
|
||||
Reference in New Issue
Block a user