Parsers, Core Files and Dataset Controllers
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package seng202.group9.Core;
|
||||
|
||||
import seng202.group9.Controller.DataException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
@@ -41,7 +43,19 @@ public class Airline {
|
||||
this.country = country;
|
||||
this.routes = new ArrayList<Route>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Airline(String name, String alias, String IATA, String ICAO, String callSign, String country, String active){
|
||||
this.ID = -1;
|
||||
this.IATA = IATA;
|
||||
this.ICAO = ICAO;
|
||||
this.name = name;
|
||||
this.alias = alias;
|
||||
this.callSign = callSign;
|
||||
this.active = active;
|
||||
this.country = country;
|
||||
this.routes = new ArrayList<Route>();
|
||||
}
|
||||
/**
|
||||
* Changes the ID of the Airline this is correlated to the database.
|
||||
* @param iD
|
||||
@@ -117,8 +131,12 @@ public class Airline {
|
||||
* get the ID of relative to the database
|
||||
* @return
|
||||
*/
|
||||
public int getID(){
|
||||
return ID;
|
||||
public int getID() throws DataException {
|
||||
if (this.ID == -1){
|
||||
throw new DataException("ID not set.");
|
||||
}else{
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* get the IATA code
|
||||
@@ -194,6 +212,22 @@ public class Airline {
|
||||
routes.add(routesToAdd.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* deletes a route by matching the route class/pointer in routes array keep in mind that the array position will change for all indexs after this.
|
||||
* @param route
|
||||
*/
|
||||
public void delRoutes(Route route){
|
||||
routes.remove(route);
|
||||
}
|
||||
|
||||
/**
|
||||
* deletes a route by matching index keep in mind that the array position will change for all indexs after this.
|
||||
* @param index
|
||||
*/
|
||||
public void delRoutes(int index){
|
||||
routes.remove(index);
|
||||
}
|
||||
/**
|
||||
* returns the name of the airline when concatenated to a string.
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,7 @@ public class Airport {
|
||||
private double longitude;
|
||||
private double latitude;
|
||||
private String city;
|
||||
private String country;
|
||||
private ArrayList<Route> departureRoutes = new ArrayList<Route>();
|
||||
private ArrayList<Route> arrivalRoutes = new ArrayList<Route>();
|
||||
|
||||
@@ -31,7 +32,7 @@ public class Airport {
|
||||
* @param longitude
|
||||
* @param latitude
|
||||
*/
|
||||
public Airport(int ID, String name, String city, String IATA_FFA, String ICAO, double latitude, double longitude
|
||||
public Airport(int ID, String name, String city, String country, String IATA_FFA, String ICAO, double latitude, double longitude
|
||||
, double altitude){
|
||||
this.ID = ID;
|
||||
this.name = name;
|
||||
@@ -41,6 +42,7 @@ public class Airport {
|
||||
this.longitude = longitude;
|
||||
this.latitude = latitude;
|
||||
this.city = city;
|
||||
this.country = country;
|
||||
}
|
||||
/**
|
||||
* Secondary Constructor the ID needs to be set after.
|
||||
@@ -51,7 +53,7 @@ public class Airport {
|
||||
* @param longitude
|
||||
* @param latitude
|
||||
*/
|
||||
public Airport(String name, String city, String IATA_FFA, String ICAO, double latitude, double longitude
|
||||
public Airport(String name, String city, String country, String IATA_FFA, String ICAO, double latitude, double longitude
|
||||
, double altitude){
|
||||
this.ID = -1;
|
||||
this.name = name;
|
||||
@@ -61,6 +63,7 @@ public class Airport {
|
||||
this.longitude = longitude;
|
||||
this.latitude = latitude;
|
||||
this.city = city;
|
||||
this.country = country;
|
||||
}
|
||||
/**
|
||||
* returns the IATA/FFA code
|
||||
@@ -148,7 +151,7 @@ public class Airport {
|
||||
public void setArrivalRoutes(ArrayList<Route> arrivalRoutes) {
|
||||
//the array list must be clones else future errors may occur
|
||||
this.arrivalRoutes = new ArrayList<Route>();
|
||||
for (int i = 0; i < departureRoutes.size(); i ++){
|
||||
for (int i = 0; i < arrivalRoutes.size(); i ++){
|
||||
this.arrivalRoutes.add(arrivalRoutes.get(i));
|
||||
}
|
||||
}
|
||||
@@ -235,6 +238,15 @@ public class Airport {
|
||||
public void addDepartureRoutes(Route route){
|
||||
departureRoutes.add(route);
|
||||
}
|
||||
/**
|
||||
* Adds each member of routes to array list;
|
||||
* @param routes
|
||||
*/
|
||||
public void addDepartureRoutes(ArrayList<Route> routes){
|
||||
for (int i = 0; i < routes.size(); i ++){
|
||||
addDepartureRoutes(routes.get(i));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* add arriving routes to this airport
|
||||
* @param route
|
||||
@@ -242,12 +254,38 @@ public class Airport {
|
||||
public void addArrivalRoutes(Route route){
|
||||
arrivalRoutes.add(route);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds each member of routes to array list;
|
||||
* @param routes
|
||||
*/
|
||||
public void addArrivalRoutes(ArrayList<Route> routes){
|
||||
for (int i = 0; i < routes.size(); i ++){
|
||||
addArrivalRoutes(routes.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* deletes a member of arrival routes by matching route pointer
|
||||
* @param route
|
||||
*/
|
||||
public void delArrivalRoutes(Route route){
|
||||
arrivalRoutes.remove(route);
|
||||
}
|
||||
|
||||
/**
|
||||
* deletes a member of arrival routes by index
|
||||
* @param index
|
||||
*/
|
||||
public void delArrivalRoutes(int index){
|
||||
arrivalRoutes.remove(index);
|
||||
}
|
||||
/**
|
||||
* Information of the airport returned in String format.
|
||||
*/
|
||||
@Override
|
||||
public String toString(){
|
||||
return this.city+" Airport has ICAO: "+this.ICAO+", IATA/FFA: "+this.IATA_FFA+" and is located at ("+this.latitude+", "+this.longitude
|
||||
+ ").\n It has "+this.departureRoutes.size()+" departing routes and "+this.arrivalRoutes+" arriving routes.";
|
||||
+ ").\n It has "+this.departureRoutes.size()+" departing routes and "+this.arrivalRoutes.size()+" arriving routes.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ import java.util.ArrayList;
|
||||
|
||||
public class City {
|
||||
private String name;
|
||||
private String timezone;
|
||||
private String country;
|
||||
private double timezone;
|
||||
private String timeOlson;
|
||||
private ArrayList<Airport> airports;
|
||||
|
||||
public City(String name, String timezone, String timeOlson){
|
||||
public City(String name, String country, double timezone, String timeOlson){
|
||||
this.name = name;
|
||||
this.country = country;
|
||||
this.timezone = timezone;
|
||||
this.timeOlson = timeOlson;
|
||||
this.airports = new ArrayList<Airport>();
|
||||
@@ -19,7 +21,11 @@ public class City {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setTimezone(String timezone) {
|
||||
public void setCountry(String country){
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public void setTimezone(double timezone) {
|
||||
this.timezone = timezone;
|
||||
}
|
||||
|
||||
@@ -28,14 +34,22 @@ public class City {
|
||||
}
|
||||
|
||||
public void setAirports(ArrayList<Airport> airports) {
|
||||
this.airports = airports;
|
||||
this.airports = new ArrayList<Airport>();
|
||||
for (int i = 0; i < airports.size(); i ++) {
|
||||
this.airports.add(airports.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getTimezone(){
|
||||
|
||||
public String getCountry(){
|
||||
return country;
|
||||
}
|
||||
|
||||
|
||||
public double getTimezone(){
|
||||
return timezone;
|
||||
}
|
||||
|
||||
@@ -50,4 +64,22 @@ public class City {
|
||||
public void addAirport(Airport airport){
|
||||
airports.add(airport);
|
||||
}
|
||||
|
||||
public void addAirport(ArrayList<Airport> airports){
|
||||
for (int i = 0; i < airports.size(); i++){
|
||||
addAirport(airports.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void delAirport(Airport airport){
|
||||
airports.remove(airport);
|
||||
}
|
||||
|
||||
public void delAirport(int index) {
|
||||
airports.remove(index);
|
||||
}
|
||||
@Override
|
||||
public String toString(){
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
|
||||
public class Country {
|
||||
private String DST, name;
|
||||
private ArrayList<City> cities = new ArrayList<City>();
|
||||
private ArrayList<Airline> airlines = new ArrayList<Airline>();
|
||||
|
||||
public Country(String DST, String name){
|
||||
@@ -20,7 +21,10 @@ public class Country {
|
||||
}
|
||||
|
||||
public void setAirlines(ArrayList<Airline> airlines) {
|
||||
this.airlines = airlines;
|
||||
this.airlines = new ArrayList<Airline>();
|
||||
for (int i = 0; i < airlines.size(); i ++) {
|
||||
this.airlines.add(airlines.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public String getDST(){
|
||||
@@ -38,4 +42,43 @@ public class Country {
|
||||
public void addAirline(Airline airline){
|
||||
this.airlines.add(airline);
|
||||
}
|
||||
|
||||
public void addAirline(ArrayList<Airline> airlines){
|
||||
for (int i = 0; i < airlines.size(); i++){
|
||||
addAirline(airlines.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void delAirline(Airline airline){
|
||||
airlines.remove(airline);
|
||||
}
|
||||
|
||||
public void delAirline(int index){
|
||||
airlines.remove(index);
|
||||
}
|
||||
|
||||
public void setCities(ArrayList<City> cities){
|
||||
this.cities = new ArrayList<City>();
|
||||
for (int i = 0; i < cities.size(); i++){
|
||||
this.cities.add(cities.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void addCities(City city){
|
||||
this.cities.add(city);
|
||||
}
|
||||
|
||||
public void addCities(ArrayList<City> cities){
|
||||
for (int i = 0; i < cities.size(); i++){
|
||||
this.cities.add(cities.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void delCities(City city){
|
||||
this.cities.remove(city);
|
||||
}
|
||||
|
||||
public void delCities(int index){
|
||||
this.cities.remove(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,16 @@ import java.util.ArrayList;
|
||||
public class FlightPath {
|
||||
private int ID;
|
||||
private ArrayList<FlightPoint> flightPoints;
|
||||
private Airport departureAirport;
|
||||
private Airport arrivalAirport;
|
||||
|
||||
public FlightPath(int ID, Airport departureAirport, Airport arrivalAirport){
|
||||
private String departureAirport;
|
||||
private String arrivalAirport;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ID id of the the flight path in the database
|
||||
* @param departureAirport Iata/FFA of the airport
|
||||
* @param arrivalAirport IATA/FFA of the airport
|
||||
*/
|
||||
public FlightPath(int ID, String departureAirport, String arrivalAirport){
|
||||
this.ID = ID;
|
||||
this.departureAirport = departureAirport;
|
||||
this.arrivalAirport = arrivalAirport;
|
||||
@@ -20,22 +26,17 @@ public class FlightPath {
|
||||
}
|
||||
|
||||
public void setFlightPoints(ArrayList<FlightPoint> flightPoints) {
|
||||
this.flightPoints = flightPoints;
|
||||
this.flightPoints = new ArrayList<FlightPoint>();
|
||||
for (int i = 0; i < flightPoints.size(); i ++) {
|
||||
this.flightPoints = flightPoints;
|
||||
}
|
||||
}
|
||||
|
||||
public Airport getDepartureAirport() {
|
||||
return departureAirport;
|
||||
}
|
||||
|
||||
public void setDepartureAirport(Airport departureAirport) {
|
||||
public void setDepartureAirport(String departureAirport) {
|
||||
this.departureAirport = departureAirport;
|
||||
}
|
||||
|
||||
public Airport getArrivalAirport() {
|
||||
return arrivalAirport;
|
||||
}
|
||||
|
||||
public void setArrivalAirport(Airport arrivalAirport) {
|
||||
public void setArrivalAirport(String arrivalAirport) {
|
||||
this.arrivalAirport = arrivalAirport;
|
||||
}
|
||||
|
||||
@@ -47,11 +48,11 @@ public class FlightPath {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public Airport departsFrom(){
|
||||
public String departsFrom(){
|
||||
return departureAirport;
|
||||
}
|
||||
|
||||
public Airport arrivesAt(){
|
||||
public String arrivesAt(){
|
||||
return arrivalAirport;
|
||||
}
|
||||
|
||||
@@ -62,4 +63,22 @@ public class FlightPath {
|
||||
public void addFlightPoint(FlightPoint flightPoint){
|
||||
flightPoints.add(flightPoint);
|
||||
}
|
||||
|
||||
public void addFlightPoint(FlightPoint flightPoint, int index){
|
||||
flightPoints.add(index, flightPoint);
|
||||
}
|
||||
|
||||
public void delFlightPoint(FlightPoint flightPoint){
|
||||
flightPoints.remove(flightPoint);
|
||||
}
|
||||
|
||||
public void delFlightPoint(int index){
|
||||
flightPoints.remove(index);
|
||||
}
|
||||
|
||||
public void addFlightPoint(ArrayList<FlightPoint> flightPoints){
|
||||
for (int i = 0; i < flightPoints.size(); i ++){
|
||||
this.flightPoints.add(flightPoints.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,39 @@
|
||||
package seng202.group9.Core;
|
||||
|
||||
import seng202.group9.Controller.DataException;
|
||||
|
||||
public class FlightPoint {
|
||||
private String name;
|
||||
private int ID;
|
||||
private int indexID;
|
||||
private String type;
|
||||
private String via;
|
||||
private String heading;
|
||||
private float altitude;//note float has a max value so they may try to break this
|
||||
private float legDistance;
|
||||
private float totalDistance;
|
||||
private float latitude;
|
||||
private float longitude;
|
||||
|
||||
private int heading;
|
||||
private double altitude;//note double has a max value so they may try to break this
|
||||
private double legDistance;
|
||||
private double totalDistance;
|
||||
private double latitude;
|
||||
private double longitude;
|
||||
|
||||
public FlightPoint(String type, String via, 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.ID = -1;
|
||||
this.indexID = -1;
|
||||
this.type = type;
|
||||
this.via = via;
|
||||
this.heading = 0;
|
||||
this.altitude = altitude;
|
||||
this.legDistance = 0.0;
|
||||
this.totalDistance = 0.0;
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public FlightPoint(String name, int ID, int indexID, String type, String via,
|
||||
String heading, float altitude, float legDistance, float totalDistance,
|
||||
float latitude, float longitude){
|
||||
int heading, double altitude, double legDistance, double totalDistance,
|
||||
double latitude, double longitude){
|
||||
this.name = name;
|
||||
this.ID = ID;
|
||||
this.indexID = indexID;
|
||||
@@ -28,9 +46,13 @@ public class FlightPoint {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public int getIndexID() {
|
||||
return indexID;
|
||||
|
||||
public int getIndexID() throws DataException {
|
||||
if (this.ID == -1){
|
||||
throw new DataException("ID not set.");
|
||||
}else{
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
|
||||
public void setIndexID(int indexID) {
|
||||
@@ -53,36 +75,40 @@ public class FlightPoint {
|
||||
this.via = via;
|
||||
}
|
||||
|
||||
public void setHeading(String heading) {
|
||||
public void setHeading(int heading) {
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
public void setAltitude(float altitude) {
|
||||
public void setAltitude(double altitude) {
|
||||
this.altitude = altitude;
|
||||
}
|
||||
|
||||
public void setLegDistance(float legDistance) {
|
||||
public void setLegDistance(double legDistance) {
|
||||
this.legDistance = legDistance;
|
||||
}
|
||||
|
||||
public void setTotalDistance(float totalDistance) {
|
||||
public void setTotalDistance(double totalDistance) {
|
||||
this.totalDistance = totalDistance;
|
||||
}
|
||||
|
||||
public void setLatitude(float latitude) {
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public void setLongitude(float longitude) {
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getID(){
|
||||
return ID;
|
||||
|
||||
public int getID() throws DataException {
|
||||
if (this.ID == -1){
|
||||
throw new DataException("ID not set.");
|
||||
}else{
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
|
||||
public int getIndex(){
|
||||
@@ -97,27 +123,27 @@ public class FlightPoint {
|
||||
return via;
|
||||
}
|
||||
|
||||
public String getHeading(){
|
||||
public int getHeading(){
|
||||
return heading;
|
||||
}
|
||||
|
||||
public float getAltitude(){
|
||||
public double getAltitude(){
|
||||
return altitude;
|
||||
}
|
||||
|
||||
public float getLegDistance(){
|
||||
public double getLegDistance(){
|
||||
return legDistance;
|
||||
}
|
||||
|
||||
public float getTotalDistance(){
|
||||
public double getTotalDistance(){
|
||||
return totalDistance;
|
||||
}
|
||||
|
||||
public float getLongitude(){
|
||||
public double getLongitude(){
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public float getLatitude(){
|
||||
public double getLatitude(){
|
||||
return latitude;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user