Refactored some variables

main
YaFedImYaEatIm 9 years ago
parent 76da24c06e
commit 58c2c6a839

@ -2030,7 +2030,7 @@
2070,"Jubail","Jubail","Saudi Arabia","","OEJB",27.039028,49.405083,26,3,"U","Asia/Riyadh"
2071,"King Faisal Naval Base","Jeddah","Saudi Arabia","","OEJF",21.3481,39.173033,7,3,"U","Asia/Riyadh"
2072,"King Abdulaziz Intl","Jeddah","Saudi Arabia","JED","OEJN",21.679564,39.156536,48,3,"U","Asia/Riyadh"
2073,"King Khaled Military City","King Khalid Mil.city","Saudi Arabia","HBT","OEKK",27.900917,45.528194,1352,3,"U","Asia/Riyadh"
2073,"King Khaled Military City","King Khalid Mil.cityName","Saudi Arabia","HBT","OEKK",27.900917,45.528194,1352,3,"U","Asia/Riyadh"
2074,"Prince Mohammad Bin Abdulaziz","Madinah","Saudi Arabia","MED","OEMA",24.553422,39.705061,2151,3,"U","Asia/Riyadh"
2075,"Nejran","Nejran","Saudi Arabia","EAM","OENG",17.611436,44.419169,3982,3,"U","Asia/Riyadh"
2076,"Qaisumah","Hafr Al-batin","Saudi Arabia","AQI","OEPA",28.335192,46.125069,1174,3,"U","Asia/Riyadh"
@ -7874,7 +7874,7 @@
9308,"Dawu","Lvliang","China","LLV",\N,37.683333,111.142778,3020,8,"N","Asia/Chongqing"
9309,"Delft Central","Delft","Netherlands","",\N,52.006667,4.356667,0,1,"E","Europe/Amsterdam"
9310,"Yading Daocheng","Daocheng","China","DCY","ZUDC",29.3231,100.0533,14472,8,"N","Asia/Chongqing"
9311,"Gannan","Xiahe city","China","GXH","ZLXH",34.4909,102.3719,10466,8,"N","Asia/Chongqing"
9311,"Gannan","Xiahe cityName","China","GXH","ZLXH",34.4909,102.3719,10466,8,"N","Asia/Chongqing"
9312,"Komandoo","Komandoo","Maldives","",\N,5.494003,73.424183,0,5,"N","Indian/Maldives"
9313,"Komandoo","Komandoo","Maldives","",\N,5.494003,73.424183,0,5,"N","Indian/Maldives"
9314,"Meck Island Airstrip","Meck Island","Marshall Islands","",\N,9,167.726944,10,12,"Z","Pacific/Majuro"

Binary file not shown.

@ -101,14 +101,14 @@ public class App extends Application
System.out.println(currentDataset.importRoute("res/Samples/Routes.txt"));
} catch (DataException e) {
e.printStackTrace();
}*/
}
//testing out flight parser
try {
System.out.println(currentDataset.importFlight("res/Samples/NZCH-WSSS.csv"));
} catch (DataException e) {
e.printStackTrace();
}
}*/
}

@ -1,8 +1,6 @@
package seng202.group9.Controller;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import seng202.group9.Core.*;
import java.sql.Connection;
@ -391,13 +389,13 @@ public class Dataset {
numOfDuplicates ++;
}else{
//insert import into database
String airName = airlinesToImport.get(i).getName().replace("'", "''").replace("\"", "\"\"");
String airAlias = airlinesToImport.get(i).getAlias().replace("'", "''").replace("\"", "\"\"");
String airIATA = airlinesToImport.get(i).getIATA().replace("'", "''").replace("\"", "\"\"");
String airICAO = airlinesToImport.get(i).getICAO().replace("'", "''").replace("\"", "\"\"");
String airCallsign = airlinesToImport.get(i).getCallSign().replace("'", "''").replace("\"", "\"\"");
String airCountry = airlinesToImport.get(i).getCountry().replace("'", "''").replace("\"", "\"\"");
String airActive = airlinesToImport.get(i).getActive().replace("'", "''").replace("\"", "\"\"");
String airName = airlinesToImport.get(i).getName().replace("\"", "\"\"");
String airAlias = airlinesToImport.get(i).getAlias().replace("\"", "\"\"");
String airIATA = airlinesToImport.get(i).getIATA().replace("\"", "\"\"");
String airICAO = airlinesToImport.get(i).getICAO().replace("\"", "\"\"");
String airCallsign = airlinesToImport.get(i).getCallSign().replace("\"", "\"\"");
String airCountry = airlinesToImport.get(i).getCountryName().replace("\"", "\"\"");
String airActive = airlinesToImport.get(i).getActive().replace("\"", "\"\"");
if (numOfAirlines > 0){
insertAirlineQuery += ",";
}
@ -467,8 +465,8 @@ public class Dataset {
} else {
//airport variables
String airpName = airportsToImport.get(i).getName().replace("\"", "\"\"");
String airpCity = airportsToImport.get(i).getCity().replace("\"", "\"\"");
String airpCountry = airportsToImport.get(i).getCountry().replace("\"", "\"\"");
String airpCity = airportsToImport.get(i).getCityName().replace("\"", "\"\"");
String airpCountry = airportsToImport.get(i).getCountryName().replace("\"", "\"\"");
String airpIATA_FFA = airportsToImport.get(i).getIATA_FFA().replace("\"", "\"\"");
String airpICAO = airportsToImport.get(i).getICAO().replace("\"", "\"\"");
double airpLat = airportsToImport.get(i).getLatitude();
@ -779,7 +777,7 @@ public class Dataset {
String insertAirlineQuery = "INSERT INTO `" + this.name + "_Airline` (`Name`, `Alias`, `IATA`, `ICAO`" +
", `Callsign`, `Country`, `Active`) VALUES (\""+airlineToAdd.getName()+"\", \"" + airlineToAdd.getAlias() + "\", " +
"\"" + airlineToAdd.getIATA() + "\", \"" + airlineToAdd.getICAO() + "\", \"" + airlineToAdd.getCallSign() + "\", " +
"\"" + airlineToAdd.getCountry() + "\", \"" + airlineToAdd.getActive() + "\");";
"\"" + airlineToAdd.getCountryName() + "\", \"" + airlineToAdd.getActive() + "\");";
stmt.execute(insertAirlineQuery);
//get the airline id
stmt = c.createStatement();
@ -836,8 +834,8 @@ public class Dataset {
//add the airport
stmt = c.createStatement();
String insertAirportQuery = "INSERT INTO `" + this.name + "_Airport` (`Name`, `City`, `Country`, `IATA/FFA`, " +
"`ICAO`, `Latitude`, `Longitude`, `Altitude`) VALUES (\""+airportToAdd.getName()+"\", \""+airportToAdd.getCity()+"\", " +
"\""+airportToAdd.getCountry()+"\", \""+airportToAdd.getIATA_FFA()+"\", \""+airportToAdd.getICAO()+"\", " +
"`ICAO`, `Latitude`, `Longitude`, `Altitude`) VALUES (\""+airportToAdd.getName()+"\", \""+airportToAdd.getCityName()+"\", " +
"\""+airportToAdd.getCountryName()+"\", \""+airportToAdd.getIATA_FFA()+"\", \""+airportToAdd.getICAO()+"\", " +
""+airportToAdd.getLatitude()+", "+airportToAdd.getLongitude()+", "+airportToAdd.getAltitude()+");";
stmt.execute(insertAirportQuery);
//get the airport id

@ -17,9 +17,10 @@ public class Airline {
private String alias;
private String callSign;
private String active;
private String country;
private String countryName;
private ArrayList<Route> routes;
private Country country = null;
/**
* Constructor
*
@ -29,10 +30,10 @@ public class Airline {
* @param IATA
* @param ICAO
* @param callSign
* @param country
* @param countryName
* @param active
*/
public Airline(int ID, String name, String alias, String IATA, String ICAO, String callSign, String country, String active){
public Airline(int ID, String name, String alias, String IATA, String ICAO, String callSign, String countryName, String active){
this.ID = ID;
this.IATA = IATA;
this.ICAO = ICAO;
@ -40,12 +41,12 @@ public class Airline {
this.alias = alias;
this.callSign = callSign;
this.active = active;
this.country = country;
this.countryName = countryName;
this.routes = new ArrayList<Route>();
}
public Airline(String name, String alias, String IATA, String ICAO, String callSign, String country, String active){
public Airline(String name, String alias, String IATA, String ICAO, String callSign, String countryName, String active){
this.ID = -1;
this.IATA = IATA;
this.ICAO = ICAO;
@ -53,7 +54,7 @@ public class Airline {
this.alias = alias;
this.callSign = callSign;
this.active = active;
this.country = country;
this.countryName = countryName;
this.routes = new ArrayList<Route>();
}
/**
@ -109,10 +110,10 @@ public class Airline {
}
/**
* Changes Country the Airline belongs to
* @param country
* @param countryName
*/
public void setCountry(String country) {
this.country = country;
public void setCountryName(String countryName) {
this.countryName = countryName;
}
/**
* Sets routes to the airline
@ -181,12 +182,28 @@ public class Airline {
return active;
}
/**
* get the country the airline belongs to
* get the countryName the airline belongs to
* @return
*/
public String getCountry(){
public String getCountryName(){
return countryName;
}
/**
* gets the Country class that this airline belongs to
* @return
*/
public Country getCountry() {
return country;
}
/**
* sets the country class this airline belongs to
* @param country
*/
public void setCountry(Country country) {
this.country = country;
}
/**
* get routes the airline flies
* @return

@ -16,8 +16,10 @@ public class Airport {
private double altitude;
private double longitude;
private double latitude;
private String city;
private String country;
private String cityName;
private City city;
private String countryName;
private Country country;
private ArrayList<Route> departureRoutes = new ArrayList<Route>();
private ArrayList<Route> arrivalRoutes = new ArrayList<Route>();
@ -25,14 +27,15 @@ public class Airport {
* Constructor
* @param ID from the database
* @param name Name of the airport
* @param city city of the airport
* @param cityName cityName of the airport
* @param countryName name of Country the airport belongs to
* @param IATA_FFA
* @param ICAO
* @param altitude
* @param longitude
* @param latitude
*/
public Airport(int ID, String name, String city, String country, String IATA_FFA, String ICAO, double latitude, double longitude
public Airport(int ID, String name, String cityName, String countryName, String IATA_FFA, String ICAO, double latitude, double longitude
, double altitude){
this.ID = ID;
this.name = name;
@ -41,19 +44,19 @@ public class Airport {
this.altitude = altitude;
this.longitude = longitude;
this.latitude = latitude;
this.city = city;
this.country = country;
this.cityName = cityName;
this.countryName = countryName;
}
/**
* Secondary Constructor the ID needs to be set after.
* @param city City of airport
* @param cityName City of airport
* @param IATA_FFA
* @param ICAO
* @param altitude
* @param longitude
* @param latitude
*/
public Airport(String name, String city, String country, String IATA_FFA, String ICAO, double latitude, double longitude
public Airport(String name, String cityName, String countryName, String IATA_FFA, String ICAO, double latitude, double longitude
, double altitude){
this.ID = -1;
this.name = name;
@ -62,8 +65,8 @@ public class Airport {
this.altitude = altitude;
this.longitude = longitude;
this.latitude = latitude;
this.city = city;
this.country = country;
this.cityName = cityName;
this.countryName = countryName;
}
/**
* returns the IATA/FFA code
@ -127,11 +130,11 @@ public class Airport {
this.longitude = longitude;
}
/**
* sets the city of the airport (which city it is in)
* @param city
* sets the cityName of the airport (which cityName it is in)
* @param cityName
*/
public void setCity(String city) {
this.city = city;
public void setCityName(String cityName) {
this.cityName = cityName;
}
/**
* set the routes that depart from it
@ -145,12 +148,12 @@ public class Airport {
}
}
public String getCountry() {
return country;
public String getCountryName() {
return countryName;
}
public void setCountry(String country) {
this.country = country;
public void setCountryName(String countryName) {
this.countryName = countryName;
}
/**
@ -220,12 +223,44 @@ public class Airport {
return latitude;
}
/**
* gets the city the airport is located in
* gets the cityName the airport is located in
* @return City of Airport
*/
public String getCity(){
public String getCityName(){
return cityName;
}
/**
* gets the city class asssociated wit hthis airport
* @return
*/
public City getCity() {
return city;
}
/**
* sets the city class associated with this airport
* @param city
*/
public void setCity(City city) {
this.city = city;
}
/**
* get country class associated with this airport
* @return
*/
public Country getCountry() {
return country;
}
/**
* set country class associated with this airport
* @param country
*/
public void setCountry(Country country) {
this.country = country;
}
/**
* gets the routes that depart from this airport
* @return Routes Departing from Airport
@ -321,7 +356,7 @@ public class Airport {
@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
return this.cityName +" 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.size()+" arriving routes.";
}
}

@ -15,6 +15,9 @@ public class Route {
private String airline;
private String departureAirport;
private String arrivalAirport;
private Airport sourceAirport;
private Airport destinationAirport;
/**
* Constructor for pulling from database
* @param airline
@ -159,6 +162,38 @@ public class Route {
return arrivalAirport;
}
/**
* get Airport class that is bound with the destination of the airport
* @return
*/
public Airport getDestinationAirport() {
return destinationAirport;
}
/**
* set Airport class that is bound with the destination of the airport
* @param destinationAirport
*/
public void setDestinationAirport(Airport destinationAirport) {
this.destinationAirport = destinationAirport;
}
/**
* get Airport class that is bound with the source airport
* @return
*/
public Airport getSourceAirport() {
return sourceAirport;
}
/**
* set Airport class that is bound with the source airport
* @param sourceAirport
*/
public void setSourceAirport(Airport sourceAirport) {
this.sourceAirport = sourceAirport;
}
/**
* Checks is passed route is a duplicate of the current one if so it throws an DataException
*/

@ -56,7 +56,7 @@ public class AirlineTest extends TestCase {
assertTrue(allNipponAirways.getIATA() == "NH");// test iata
assertTrue(allNipponAirways.getICAO() == "ANA");// test icao
assertTrue(allNipponAirways.getCallSign() == "ALL NIPPON");// test call sign
assertTrue(allNipponAirways.getCountry() == "Japan");// test country
assertTrue(allNipponAirways.getCountryName() == "Japan");// test country
assertTrue(allNipponAirways.getActive() == "Y");// get active
//check set
allNipponAirways.setID(322);//ID
@ -81,8 +81,8 @@ public class AirlineTest extends TestCase {
allNipponAirways.setCallSign("NIKE RULES");//Call Sign
assertTrue(allNipponAirways.getCallSign() =="NIKE RULES");
allNipponAirways.setCountry("Nikeland");//Country
assertTrue(allNipponAirways.getCountry() == "Nikeland");
allNipponAirways.setCountryName("Nikeland");//Country
assertTrue(allNipponAirways.getCountryName() == "Nikeland");
allNipponAirways.setActive("N");//Active
assertTrue(allNipponAirways.getActive() == "N");

@ -34,7 +34,7 @@ public class AirportUnitTest {
fail("No Exception should be thrown by the constructor where the ID is already set bye trying to get the ID.");
}
assertEquals(heathrow.getName(), "Heathrow");
assertEquals(heathrow.getCity(), "London");//check city
assertEquals(heathrow.getCityName(), "London");//check city
assertEquals(heathrow.getIATA_FFA(), "LHR");//check IATA/FFA
assertEquals(heathrow.getICAO(), "EGLL");//check ICAO
assertTrue(heathrow.getLatitude() == 51.4775);//check latitude
@ -51,8 +51,8 @@ public class AirportUnitTest {
}
heathrow.setName("Hearthstone");//check name
assertEquals(heathrow.getName(), "Hearthstone");
heathrow.setCity("Blizzard Servers");//check city
assertEquals(heathrow.getCity(), "Blizzard Servers");
heathrow.setCityName("Blizzard Servers");//check city
assertEquals(heathrow.getCityName(), "Blizzard Servers");
heathrow.setIATA_FFA("HTS");//test set IATA/FFA
assertEquals(heathrow.getIATA_FFA(), "HTS");
heathrow.setICAO("BLIZ");// test set ICAO

Loading…
Cancel
Save