Added Cannot delte if the flight path only has 2 points
This commit is contained in:
Binary file not shown.
@@ -2,6 +2,7 @@ package seng202.group9.Controller;
|
||||
|
||||
|
||||
import javafx.scene.chart.PieChart;
|
||||
import javafx.scene.control.Alert;
|
||||
import seng202.group9.Core.*;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -1160,7 +1161,7 @@ public class Dataset {
|
||||
flightPathDictionary.put(pathID, newPath);
|
||||
flightPaths.add(newPath);
|
||||
FlightPoint sourcePoint = new FlightPoint(sourceAirport, pathID);
|
||||
FlightPoint destinationPoint = new FlightPoint(sourceAirport, pathID);
|
||||
FlightPoint destinationPoint = new FlightPoint(destAirport, pathID);
|
||||
try{
|
||||
addFlightPointToPath(sourcePoint);
|
||||
addFlightPointToPath(destinationPoint);
|
||||
@@ -1591,6 +1592,7 @@ public class Dataset {
|
||||
* @param flightPoint
|
||||
*/
|
||||
public void deleteFlightPoint(FlightPoint flightPoint, FlightPath flightPath){
|
||||
if (flightPath.getFlightPoints().size() > 2){
|
||||
//drop the tables
|
||||
Connection c = null;
|
||||
Statement stmt = null;
|
||||
@@ -1618,6 +1620,13 @@ public class Dataset {
|
||||
flightPointDictionary.remove(flightPoint);
|
||||
updateFlightPointInfo(flightPath);
|
||||
updateFlightPath(flightPath);
|
||||
}else{
|
||||
Alert cannotDelete = new Alert(Alert.AlertType.ERROR);
|
||||
cannotDelete.setTitle("Flight Path Error");
|
||||
cannotDelete.setHeaderText("Cannot Delete Flight Point.");
|
||||
cannotDelete.setContentText("You cannot have less than 2 Points in a Flight Path.");
|
||||
cannotDelete.showAndWait();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user