From d84346de60796a5f0993cad983bf913e32ad5604 Mon Sep 17 00:00:00 2001 From: YaFedImYaEatIm Date: Wed, 14 Sep 2016 11:51:39 +1200 Subject: [PATCH] Added singular Airport adding --- res/userdb.db | Bin 4354048 -> 4354048 bytes .../java/seng202/group9/Controller/App.java | 8 +- .../seng202/group9/Controller/Dataset.java | 120 ++++++++++++++++++ .../java/seng202/group9/Core/Airline.java | 12 +- .../java/seng202/group9/Core/Airport.java | 11 ++ 5 files changed, 144 insertions(+), 7 deletions(-) diff --git a/res/userdb.db b/res/userdb.db index 9e3da2a8d41b37e36a67a3b7a417cfb031e79c98..1af3ac35e457e742acd38b5055ad797ffb3b09b4 100644 GIT binary patch delta 707 zcmZ9}O=uHA7zW^-`I5~xNweLosckm3*;pH68k^c`TjNib=s{4)MM6c|fPVy`ZGJ=# zJyaA!p|lYXD+H>Dh(!>4>E0}eq8CqIdJ1jSi#-)@J^2QMMPZ&{7=~}&nQwMuj?Y3x zWBEsc6w9wY_(OY^*Rm-Rt31+1$MjtaV|9G5LeZ90PD7 zj9g)QO0`qupN&GPd*OanEmu_r90+V+2N4_~L5o#Yow?7pQ9dG=!7I^%8FGv5yEo35 z$(qw{o~;Ke)|Z-dn0Xy+N1!)!nY{c1zsq&D^Cx8^-*UKT&EphwMN@r}BxQ1w*QV|i zg9Gt&s=3abyNGe7tk<330ynf;dfoGFSsW6c3gj}SdHIGlJueS(cFTORAm5Z6r0{e~ z%aqkc8QLs$QQ3}nx_C;Uby~$=U8N*>_;=lD1`^|qGK?km={j@67^(IowEkaViQ z8Oa)due|J{2wO588_IcciT&hbsPM!VZB+2HRyS$9d05!CUT-R6qTfZaMyqP{mEO@a znxRRWpbM0s*#Av?<#FB1lO{JSTq-BF6!3xyd%y?nuopU@6a1h-0J>lwbVCqy2*G~n zfdkMBVK@j8I0RAXgBTo!eu%>W9DzX?f}?N@hG7Io;W#AV1e}CZa2k?UV$1mW;5W}T B`yT)R delta 592 zcmYMw%}W$<7zgnAJn3)l}^U7g&fQ{&B8_f|1oNoH<$$+q||sa)tDT0V$+GK z=~T@UA1Q`6-<*uS&YJ10DS&`Mg#z$EArygEW=$>jNA0AD;s%C8iR+cQWlJ)0plypX z4_OLt@(cFSHqDZiPy9_=#~R##VknW;ap}pr8dg>nS6kFy(YIomSk%KLlJ1xH`b5#o zK;P6%a@-uXE~S6;lNQLe`n}!x>-XizFJrBmo5Y4& zcxd#ir!<7jiW)s1AJh@ zO(=(3;D_6A2P&Wvs-PO~LJb7Kf?Bu-bx;ot&SJW@v#2& getAirlines() { return airlines; } diff --git a/src/main/java/seng202/group9/Core/Airline.java b/src/main/java/seng202/group9/Core/Airline.java index e423c72..54ebc8d 100644 --- a/src/main/java/seng202/group9/Core/Airline.java +++ b/src/main/java/seng202/group9/Core/Airline.java @@ -205,7 +205,7 @@ public class Airline { } /** * Function Overload of addRoutes this allow the adding of a list to route - * @param routes + * @param routesToAdd array list of routes to add routes */ public void addRoutes(ArrayList routesToAdd){ for (int i = 0; i < routesToAdd.size(); i ++){ @@ -235,19 +235,19 @@ public class Airline { * @return */ public void hasDuplicate(Airline airline) throws DataException{ - if (this.name == airline.getName()){ + if (this.name.equals(airline.getName())){ throw new DataException("This Airline Name already Exists, Please Choose Another."); } - if (this.IATA != "" && this.IATA == airline.getIATA()){ + if (!this.IATA.equals("") && this.IATA.equals(airline.getIATA())){ throw new DataException("This IATA Code already Exists, Please Choose Another."); } - if (this.ICAO != "" && this.ICAO == airline.getICAO()){ + if (!this.ICAO.equals("") && this.ICAO.equals(airline.getICAO())){ throw new DataException("This ICAO Code already Exists, Please Choose Another."); } - if (this.alias != "" && this.alias == airline.getAlias()){ + if (!this.alias.equals("") && this.alias.equals(airline.getAlias())){ throw new DataException("This Alias already Exists, Please Choose Another."); } - if (this.callSign != "" && this.callSign == airline.getCallSign()){ + if (!this.callSign.equals("") && this.callSign.equals(airline.getCallSign())){ throw new DataException("This Callsign already Exists, Please Choose Another."); } } diff --git a/src/main/java/seng202/group9/Core/Airport.java b/src/main/java/seng202/group9/Core/Airport.java index 5de5e4d..8283933 100644 --- a/src/main/java/seng202/group9/Core/Airport.java +++ b/src/main/java/seng202/group9/Core/Airport.java @@ -304,6 +304,17 @@ public class Airport { distance = 6371 * c; return distance; } + public void hasDuplicate(Airport airport) throws DataException{ + if (!airport.getName().equals("") && airport.getName().equals(this.name)){ + throw new DataException("Airport Name already Exists, Please Choose Another."); + } + if (!airport.getIATA_FFA().equals("") && airport.getIATA_FFA().equals(this.name)){ + throw new DataException("Airport Name already Exists, Please Choose Another."); + } + if (!airport.getICAO().equals("") && airport.getICAO().equals(this.name)){ + throw new DataException("Airport Name already Exists, Please Choose Another."); + } + } /** * Information of the airport returned in String format. */