Added Flight POint Test as well as some Exceptions

This commit is contained in:
YaFedImYaEatIm
2016-09-19 01:43:06 +12:00
parent 548b5fe321
commit 6e3ba9775a
3 changed files with 94 additions and 2 deletions
@@ -197,7 +197,10 @@ public class FlightPoint {
* gets the Path Index ID at this point.
* @return
*/
public int getIndex(){
public int getIndex() throws DataException{
if (indexID == -1){
throw new DataException("Index ID is not set.");
}
return indexID;
}
@@ -204,7 +204,14 @@ public class FlightRDController extends Controller {
*/
public void deletePoint() {
FlightPoint toDelete = flightTableView.getSelectionModel().getSelectedItem();
int pathID = toDelete.getIndex();
int pathID = 0;
try {
pathID = toDelete.getIndex();
} catch (DataException e) {
e.printStackTrace();
System.out.println("Point is Undeletable as the Index ID is not set.");
return;
}
LinkedHashMap<Integer, FlightPath> flightPathDict = theDataSet.getFlightPathDictionary();
FlightPath toDeletesPath = flightPathDict.get(pathID);
theDataSet.deleteFlightPoint(toDelete, toDeletesPath);