0% found this document useful (0 votes)
6 views41 pages

Airport System

The document contains Java code for an airport management system using JavaFX, including classes for handling flight reservations, user login, and sign-up functionalities. It features a graphical user interface with various controls like buttons, labels, and tables to manage flight information and reservations. The code also includes validation for user inputs and a layout design for the application's main window.

Uploaded by

hafodalrubai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views41 pages

Airport System

The document contains Java code for an airport management system using JavaFX, including classes for handling flight reservations, user login, and sign-up functionalities. It features a graphical user interface with various controls like buttons, labels, and tables to manage flight information and reservations. The code also includes validation for user inputs and a layout design for the application's main window.

Uploaded by

hafodalrubai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 41

package AirportSystem1;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.*;
import javafx.stage.Stage;

public class tecketlist extends Application {


private final flaylist.Flight selectedFlight;

public tecketlist(flaylist.Flight selectedFlight) {


this.selectedFlight = selectedFlight;
AppDataStore.getInstance().set("selectedFlight",
selectedFlight.getFlightNumber());
}

@Override
public void start(Stage primaryStage) {
VBox layout = new VBox(15);
layout.setPadding(new Insets(20));

Label title = new Label("Flight Reservations - " +


selectedFlight.getFlightNumber());
title.setStyle("-fx-font-size: 20px; -fx-font-weight: bold;");

VBox flightInfo = createFlightInfoBox();


TableView<Reservation> table = createReservationTable();

Button backBtn = new Button("← Back");


backBtn.setOnAction(e -> primaryStage.close());

Button addBtn = new Button("➕ Add New Reservation");


addBtn.setOnAction(e -> showAddReservationDialog());

HBox controls = new HBox(10, backBtn, addBtn);


controls.setAlignment(Pos.CENTER_LEFT);

layout.getChildren().addAll(title, new Separator(), flightInfo, new


Label("Reservations:"), table, controls);
Scene scene = new Scene(layout, 1800, 950);

scene.getStylesheets().add(getClass().getResource("tecketlistStyle.css").toE
xternalForm());
primaryStage.setScene(scene);
primaryStage.setTitle("Reservations");
primaryStage.show();
}

private VBox createFlightInfoBox() {


GridPane grid = new GridPane();
grid.setHgap(20);
grid.setVgap(10);

grid.addRow(0, new Label("Flight:"), new


Label(selectedFlight.getFlightNumber()));
grid.addRow(1, new Label("From:"), new
Label(selectedFlight.getDeparture()));
grid.addRow(2, new Label("To:"), new
Label(selectedFlight.getDestination()));
grid.addRow(3, new Label("Plane:"), new
Label(selectedFlight.getPlaneName()));

return new VBox(10, new Label("Flight Info"), grid);


}

private TableView<Reservation> createReservationTable() {


TableView<Reservation> table = new TableView<>();

table.getColumns().addAll(
createCol("Passenger ID", "passengerId"),
createCol("Passport No", "passportNumber"),
createCol("Full Name", "fullName"),
createCol("Gender", "gender"),
createCol("Nationality", "nationality"),
createCol("Ticket Code", "ticketCode"),
createCol("Ticket Price", "ticketPrice")
);

table.setItems(getSampleReservations());
return table;
}

private TableColumn<Reservation, String> createCol(String title, String


prop) {
TableColumn<Reservation, String> col = new TableColumn<>(title);
col.setCellValueFactory(new PropertyValueFactory<>(prop));
col.setPrefWidth(200);
return col;
}

private ObservableList<Reservation> getSampleReservations() {


ObservableList<Reservation> data =
FXCollections.observableArrayList();
data.add(new Reservation("P001", "A123456", "Ahmed Ali", "Male",
"Egyptian", "T001", "$700"));
data.add(new Reservation("P002", "B987654", "Sara Moh", "Female",
"Saudi", "T002", "$650"));
return data;
}

private void showAddReservationDialog() {


Alert info = new Alert(Alert.AlertType.INFORMATION);
info.setTitle("Coming Soon");
info.setHeaderText("Reservation Dialog");
info.setContentText("This will open a reservation form.");
info.showAndWait();
}

public static class Reservation {


private final String passengerId, passportNumber, fullName, gender,
nationality, ticketCode, ticketPrice;

public Reservation(String passengerId, String passportNumber, String


fullName,
String gender, String nationality, String
ticketCode, String ticketPrice) {
this.passengerId = passengerId;
this.passportNumber = passportNumber;
this.fullName = fullName;
this.gender = gender;
this.nationality = nationality;
this.ticketCode = ticketCode;
this.ticketPrice = ticketPrice;
}

public String getPassengerId() { return passengerId; }


public String getPassportNumber() { return passportNumber; }
public String getFullName() { return fullName; }
public String getGender() { return gender; }
public String getNationality() { return nationality; }
public String getTicketCode() { return ticketCode; }
public String getTicketPrice() { return ticketPrice; }
}

public static void main(String[] args) {


launch(args);
}
}
loginButton.setMaxWidth(250);

loginButton.getStyleClass().add("login-button");

loginButton.setOnAction(event -> {
String username = usernameField.getText();
String password = passwordField.getText();
if (username.isEmpty() || password.isEmpty()) {
Alert successLoginAlert = new Alert(Alert.AlertType.INFORMATION);
successLoginAlert.setTitle("Error");
// successLoginAlert.setHeaderText("User ");
successLoginAlert.setContentText("Username Or Password Can not be
Empty!!");
successLoginAlert.showAndWait();
return;
}
if (AuthenticationService.loginUser(username,password)) {
Alert successLoginAlert = new Alert(Alert.AlertType.INFORMATION);
successLoginAlert.setTitle("Success");
successLoginAlert.setHeaderText("Success Opreation");
successLoginAlert.setContentText("passenger added seccussfully");
successLoginAlert.showAndWait();

}
else {
Alert successLoginAlert = new Alert(Alert.AlertType.INFORMATION);
successLoginAlert.setTitle("Error");
// successLoginAlert.setHeaderText("Success Opreation");
successLoginAlert.setContentText("Data that entered is incorrect");
successLoginAlert.showAndWait();

}
});

Label forgetPaasswordLabel = new Label("Forget Password?");


forgetPaasswordLabel.getStyleClass().add("forgot-pass");

Label singupLabel = new Label("SignUp");


singupLabel.getStyleClass().add("sign-up");
singupLabel.setOnMouseClicked(event -> {
SignInWindow signUp = new SignInWindow();

});

HBox forgetAndSignUp = new HBox(10,forgetPaasswordLabel,singupLabel);


forgetAndSignUp.setAlignment(Pos.CENTER);
VBox loginBox = new VBox(15,singInLabel,usernameField,passwordField,loginButton,
forgetAndSignUp);

loginBox.setAlignment(Pos.CENTER);
//loginBox.setMaxHeight(300);
loginBox.setPadding(new Insets(20));
loginBox.setMaxWidth(300);
loginBox.getStyleClass().add("login-box");

VBox footer = new VBox(5);


footer.setAlignment(Pos.CENTER);
Label footerText1Label = new Label("Designed By:");
Label footerText2Label = new Label("Eng. MohAlrubai - Eng. MohAlwashali - Eng.
HishamMutahar - Eng. MohDhaifallah");

footerText1Label.setStyle("-fx-font-size: 18px; -fx-text-fill: WHITE; -fx-font-


weight: bold; -fx-effect: dropshadow(gaussian,rgba(0,0,0,0.8),2,0.5,0,1);");
footerText2Label.setStyle("-fx-font-size: 18px; -fx-text-fill: WHITE; -fx-font-
weight: bold; -fx-effect: dropshadow(gaussian,rgba(0,0,0,0.8),2,0.5,0,1);");
footer.getChildren().addAll(footerText1Label,footerText2Label);
// footer.setLayoutX(300);
// footer.setLayoutY(600);
//footer.setPadding(new Insets(20));
StackPane footerContainer = new StackPane(footer);
footerContainer.setAlignment(Pos.CENTER);
footerContainer.setPadding(new Insets(0,0,20,0));

BorderPane mainPane = new BorderPane();


mainPane.setCenter(loginBox);
mainPane.setBottom(footerContainer);
BorderPane.setAlignment(footer,Pos.CENTER);
BorderPane.setMargin(footer,new Insets(0,0,20,0));

StackPane backgroundPane = new StackPane(mediaView,glassBackground,mainPane);

Scene scene = new Scene(backgroundPane,1800,950);

scene.getStylesheets().add(getClass().getResource("LoginStyle.css").toExternalForm());

mediaView.fitWidthProperty().bind(scene.widthProperty());
mediaView.fitHeightProperty().bind(scene.heightProperty());
mediaView.setPreserveRatio(false);

primaryStage.setTitle("Mohammed App");
primaryStage.setScene(scene);
primaryStage.show();

public static void main(String[] args) {


launch(args);
}
}
‫الكالس الثاني‬
package AirportSystem;

import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.NodeOrientation;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class SignInWindow extends Application {


public void start(Stage primaryStage) {

BorderPane borderPane = new BorderPane();


borderPane.getStyleClass().add("border-pane");

Label headerLabel = new Label("Airports Management System");


headerLabel.setStyle("-fx-font-size: 24px; -fx-font-weight: bold;");
headerLabel.setMinWidth(800);
HBox header = new HBox(headerLabel);
header.setAlignment(Pos.CENTER);
header.setPadding(new Insets(20));

VBox formBox = new VBox(40);


formBox.getStyleClass().add("form-box");
formBox.setAlignment(Pos.CENTER);
formBox.setPadding(new Insets(30));

HBox usernameBox = new HBox(10);

Label usernameLabel = new Label("Username");


TextField usernameField = new TextField();
usernameField.setPromptText("Enter username");
usernameBox.getChildren().addAll(usernameLabel,usernameField);
HBox.setHgrow(usernameField, Priority.ALWAYS);
usernameBox.setAlignment(Pos.CENTER_LEFT);

HBox genderBox = new HBox(10);


Label userGenderLabel = new Label("Gender");
ComboBox<String> genderCombo = new ComboBox<>();
genderCombo.getItems().addAll("Male","Female");
genderCombo.setPromptText("Choose Gender");
genderCombo.setPrefWidth(200);
genderCombo.setPrefHeight(30);
genderCombo.setStyle("-fx-font-size: 18px");
genderBox.getChildren().addAll(userGenderLabel,genderCombo);
HBox.setHgrow(genderCombo,Priority.ALWAYS);
genderBox.setAlignment(Pos.CENTER_LEFT);

/* RadioButton maleRadio = new RadioButton("Male");


RadioButton femaleRadio = new RadioButton("Female");
ToggleGroup genderGroup = new ToggleGroup();
maleRadio.setToggleGroup(genderGroup);
femaleRadio.setToggleGroup(genderGroup);
HBox radioContainer = new HBox(15,maleRadio,femaleRadio);
genderBox.getChildren().addAll(userGenderLabel,radioContainer);
genderBox.setAlignment(Pos.CENTER_RIGHT);*/

HBox userEmailBox = new HBox(10);


Label userEmailLabel = new Label("Email");
TextField userEmailField = new TextField();
userEmailField.setPromptText("Enter your Email");
userEmailBox.getChildren().addAll(userEmailLabel,userEmailField);
HBox.setHgrow(userEmailField,Priority.ALWAYS);
userEmailBox.setAlignment(Pos.CENTER_LEFT);

HBox passwordBox = new HBox(10);


Label passwordLabel = new Label("Password");
PasswordField passwordField = new PasswordField();
userEmailField.focusedProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue) {
String email = userEmailField.getText().trim();
if (!email.isEmpty() && !isValidEmail(email)) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Invalid Email");
alert.setHeaderText("Error");
alert.setContentText("The Email Format is invalid. Please enter a valid
email.");
alert.showAndWait();
userEmailField.requestFocus();
}
}
});
passwordField.setPromptText("Enter Password");
passwordBox.getChildren().addAll(passwordLabel,passwordField);
HBox.setHgrow(passwordField,Priority.ALWAYS);
passwordBox.setAlignment(Pos.CENTER_LEFT);

HBox confirmPasswordBox = new HBox(10);


Label confirmPasswordLabel = new Label("Conf. Password");
PasswordField confirmPasswordField = new PasswordField();
confirmPasswordField.focusedProperty().addListener(((observable, oldValue,
newValue) -> {
String password = passwordField.getText();
String confirmPassword = confirmPasswordField.getText();
if (! confirmPassword.isEmpty() && !password.equals(confirmPassword)) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setHeaderText("Error!!");
alert.setContentText("Passwords do not match.\n"+
"Please Confirm your password correctly.");
alert.showAndWait();
confirmPasswordField.clear();
confirmPasswordField.requestFocus();
}
}));
confirmPasswordField.setPromptText("Enter Password Againe");
confirmPasswordBox.getChildren().addAll(confirmPasswordLabel,confirmPasswordField);
HBox.setHgrow(confirmPasswordField,Priority.ALWAYS);
confirmPasswordBox.setAlignment(Pos.CENTER_LEFT);

HBox userCodeBox = new HBox(10);


Label userCodeLabel = new Label("Usrer Code: ");
TextField userCodeField = new TextField();
userCodeField.setPromptText("To set New Password If you Forgot");
userCodeBox.getChildren().addAll(userCodeLabel,userCodeField);
HBox.setHgrow(userEmailField,Priority.ALWAYS);
userCodeBox.setAlignment(Pos.CENTER_LEFT);

HBox buttonBox = new HBox(20);


Button loginButton = new Button("Login");
Button cancelButton = new Button("Cancel");
loginButton.getStyleClass().add("login-btn");
cancelButton.getStyleClass().add("cancel-btn");
buttonBox.getChildren().addAll(loginButton,cancelButton);
buttonBox.setAlignment(Pos.CENTER);

formBox.getChildren().addAll(usernameBox,genderBox,userEmailBox,passwordBox,confirmPassword
Box,userCodeBox,buttonBox);

VBox footer = new VBox(5);


footer.setAlignment(Pos.CENTER);
Label footerText1 = new Label("Designed By:");
Label footerText2 = new Label("Eng. MohAlrubai - Eng. MohAlwashali - Eng.
HishamMutahar - Eng. MohDhaifallah");

footerText1.setStyle("-fx-font-size: 20px; -fx-alignment: center;");

footerText2.setStyle("-fx-font-size: 20px; -fx-text-fill: #C0C0C0; -fx-alignment:


center;" +
" -fx-background-color: rgba(0,0,0,0.3); -fx-background-radius: 5;" +
"-fx-padding: 10;");
footer.getChildren().addAll(footerText1,footerText2);
footer.setPadding(new Insets(20));

borderPane.setTop(header);
borderPane.setCenter(formBox);
borderPane.setBottom(footer);
Scene scene = new Scene(borderPane,1800,950);

scene.getStylesheets().add(getClass().getResource("SinginStyle.css").toExternalForm());
scene.setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT);
primaryStage.setTitle("Sign Up");
primaryStage.setScene(scene);
primaryStage.show();

private boolean isValidEmail(String email) {


return email.matches("^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$");
}
public static void main(String[] args) {
launch(args);
}

}
Class 3 :

package AirportSystem;

import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.geometry.VPos;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.paint.CycleMethod;
import javafx.scene.paint.RadialGradient;
import javafx.scene.paint.Stop;
import javafx.scene.shape.Line;
import javafx.scene.shape.Polygon;
import javafx.scene.text.Font;
import java.lang.String;

import javafx.scene.text.FontWeight;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage;
import javafx.util.Duration;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.YearMonth;

public class ccc extends Application {


private static final int WIDTH = 1800;
private static final int HEIGHT = 950;
private static final int CLOCK_RADIUS = 120;
private static final int CLOCK_CENTER_X = 150;
private static final int CLOCK_CENTER_Y = 150;

@Override
public void start(Stage primatyStage) {

BorderPane root = new BorderPane();


root.setStyle("-fx-background-color: #f4f6f9;");

StackPane centerPane = new StackPane();


Line midLine = new Line(0,0,WIDTH,0);
midLine.setStroke(Color.BLACK);
midLine.setStrokeWidth(4);

StackPane rhombusLayer = createRhombusRow();


centerPane.getChildren().addAll(midLine,rhombusLayer);
StackPane.setAlignment(midLine,Pos.CENTER);
StackPane.setAlignment(rhombusLayer,Pos.CENTER);
root.setCenter(centerPane);

HBox dateBox = createDateBox();


dateBox.setTranslateY(-20);

HBox bottomPane = new HBox();


bottomPane.setPadding(new Insets(0,20,0,20));
bottomPane.setAlignment(Pos.BOTTOM_CENTER);

VBox clockBox = createClock();


clockBox.setAlignment(Pos.BOTTOM_LEFT);
clockBox.setTranslateY(-20);

GridPane calender = createCalender();


VBox calenderBox = new VBox(calender);
calenderBox.setAlignment(Pos.BOTTOM_RIGHT);
calenderBox.setTranslateY(-20);

HBox.setHgrow(clockBox,Priority.ALWAYS);
HBox.setHgrow(calenderBox,Priority.ALWAYS);

bottomPane.getChildren().addAll(clockBox,dateBox,calenderBox);

Label copyrightLabel1 = new Label("Designed By:");


copyrightLabel1.setFont(Font.font("Segoe UI",20));
copyrightLabel1.setTextFill(Color.WHITE);
copyrightLabel1.setAlignment(Pos.CENTER);

Label copyrightLabel2 = new Label("Eng. MohAlrubai - Eng. MohAlwashali - Eng.


HishamMutahar - Eng. MohDaifuallah");
copyrightLabel2.setFont(Font.font("Segoe UI",25));
copyrightLabel2.setTextFill(Color.WHITE);
copyrightLabel2.setAlignment(Pos.CENTER);

VBox bottomPane1 = new VBox(bottomPane,copyrightLabel1,copyrightLabel2);


bottomPane1.setAlignment(Pos.BOTTOM_CENTER);
bottomPane1.setSpacing(5);
bottomPane1.setPadding(new Insets(0,0,10,0));
root.setBottom(bottomPane1);

Scene scene = new Scene(root,WIDTH,HEIGHT);


scene.getStylesheets().add(getClass().getResource("ccccc.css").toExternalForm());
primatyStage.setTitle("airport dashboard");
primatyStage.setScene(scene);
primatyStage.show();

}
private StackPane createRhombusRow() {
StackPane layer = new StackPane();

HBox rhombusRow = new HBox(150);


rhombusRow.setAlignment(Pos.CENTER);

String[] iconPaths =
{"/AirportSystem/Pictures/m007.PNG","/AirportSystem/Pictures/s001.PNG","/AirportSystem/
Pictures/s004.PNG",
"/AirportSystem/Pictures/n003.PNG","/AirportSystem/Pictures/m005.PNG"};
String[] labels = {"Enter a trip","Flight list","Book a ticket","Listowns","User\
nmanagement"};

double rhombusHeight = 200;


double iconOverlap = rhombusHeight*0.10;
for (int i = 0;i<labels.length;i++) {

StackPane itemcontainer = new StackPane();


itemcontainer.getStyleClass().add("rhombus-item");
itemcontainer.setPickOnBounds(true);

Polygon rhombus = new Polygon(


0.0, rhombusHeight / 2,
rhombusHeight / 2, 0.0,
rhombusHeight, rhombusHeight / 2,
rhombusHeight / 2, rhombusHeight);

rhombus.getStyleClass().add("rhombus-base");

Label label = new Label(labels[i]);


label.getStyleClass().add("rhombus-label");
label.setAlignment(Pos.CENTER);
label.setTextAlignment(TextAlignment.CENTER);
label.setMaxWidth(Double.MAX_VALUE);
if (labels[i].equals("User\nmanagement")) {
label.setAlignment(Pos.CENTER);
// label.setMaxWidth(Double.MAX_VALUE);
StackPane.setAlignment(label,Pos.CENTER);
}

label.getStyleClass().add("rhombus-label");

javafx.scene.image.ImageView icon = new javafx.scene.image.ImageView(new


Image(getClass().getResourceAsStream(iconPaths[i])));

icon.setFitHeight(75);
icon.setFitWidth(120);

StackPane iconPane = new StackPane(icon);


iconPane.setTranslateY(-(rhombusHeight/2)-iconOverlap+35);

itemcontainer.getChildren().addAll(rhombus,label,iconPane);

itemcontainer.setOnMouseEntered(event ->
{
itemcontainer.setScaleX(1.17);
itemcontainer.setScaleY(1.17);
rhombus.getStyleClass().remove("rhombus-base");
rhombus.getStyleClass().add("rhombus-hover");

});
itemcontainer.setOnMouseExited(event ->
{
itemcontainer.setScaleX(1.0);
itemcontainer.setScaleY(1.0);
//iconPane.setTranslateY(-44);
rhombus.getStyleClass().remove("rhombus-hover");
rhombus.getStyleClass().add("rhombus-base");
});
rhombusRow.getChildren().add(itemcontainer);

Label titleLabel = new Label("Dashboard");


//titleLabel.setStyle("-fx-letter-spacing: 10px");
titleLabel.getStyleClass().add("dashboard-title-label");

/*StackPane titleContainer = new StackPane(titleLabel);


// titleContainer.getStyleClass().add("dashboard-title-box");*/
titleLabel.setTranslateY(-170);

layer.getChildren().addAll(titleLabel,rhombusRow);

return layer;
}
private GridPane createCalender() {
GridPane grid = new GridPane();
grid.setHgap(0);
grid.setVgap(0);
grid.setPadding(new Insets(0));
grid.setAlignment(Pos.CENTER);
grid.setStyle("-fx-max-width: 490px;");

grid.getStyleClass().add("calendar-container");

String[] days = {"Mon","Tue","Wed","Thu","Fri","Sat","Sun"};


for (int i = 0; i<days.length;i++) {
Label dayLabel = new Label(days[i]);
dayLabel.getStyleClass().add("calendar-header-label");

StackPane dayContainer = new StackPane(dayLabel);


dayContainer.getStyleClass().add("calendar-header");
dayContainer.setMinSize(70,70);
grid.add(dayContainer,i,0);
}
LocalDate today = LocalDate.now();
YearMonth ym = YearMonth.now();
int daysInMonth = ym.lengthOfMonth();
int startDay = ym.atDay(1).getDayOfWeek().getValue();

int col = (startDay+6)%7;


int row = 1;
for (int i=0; i<col;i++) {
StackPane emptyCells = new StackPane();
emptyCells.setMinSize(70,40);
emptyCells.getStyleClass().add("calendar-cell");
grid.add(emptyCells,i,row);
}

for (int day =1; day<=daysInMonth; day++) {

Label label = new Label(String.valueOf(day));


label.getStyleClass().add("calendar-day-label");

StackPane cell = new StackPane(label);


cell.setMinSize(70,40);
cell.getStyleClass().add("calendar-cell");
if (day == today.getDayOfMonth())
cell.getStyleClass().add("calendar-today");
grid.add(cell,col,row);
col++;
if (col > 6) {
col =0;
row++;
}
}
if (col!=0) {
for (int i=col;i<7;i++) {
StackPane emptyCells = new StackPane();
emptyCells.setMinSize(70,40);
emptyCells.getStyleClass().add("calendar-cell");
grid.add(emptyCells,i,row);
}
}
return grid; }
private VBox createClock() {
Canvas clockCanvas = new Canvas(300,300);
GraphicsContext gc = clockCanvas.getGraphicsContext2D();
drawClock(gc);

Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1),event ->


drawClock(gc)));

timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();

VBox clockBox = new VBox(clockCanvas);


clockBox.setAlignment(Pos.CENTER);
clockCanvas.getStyleClass().add("colck-box");

//clockBox.getStyleClass().add("clock-box");
return clockBox;

}
private void drawClock(GraphicsContext gc) {

gc.clearRect(0,0,300,300);

RadialGradient dialGradient = new


RadialGradient(0,0,CLOCK_CENTER_X,CLOCK_CENTER_Y,CLOCK_RADIUS,false,
CycleMethod.NO_CYCLE,new Stop(0.0,Color.web("#f5f5f5")),new
Stop(1.0,Color.web("#cccccc")));
gc.setFill(dialGradient);

gc.fillOval(CLOCK_CENTER_X-CLOCK_RADIUS,CLOCK_CENTER_Y-
CLOCK_RADIUS,CLOCK_RADIUS*2,CLOCK_RADIUS*2);

gc.setStroke(Color.web("#dddddd"));
gc.setLineWidth(6);
gc.strokeOval(CLOCK_CENTER_X - CLOCK_RADIUS+3, CLOCK_CENTER_Y - CLOCK_RADIUS+3,
(CLOCK_RADIUS-3)*2, (CLOCK_RADIUS-3)*2);

gc.setFill(Color.web("#333333"));
gc.setFont(Font.font("Segoe UI", FontWeight.BOLD,18));
gc.setTextAlign(TextAlignment.CENTER);
gc.setTextBaseline(VPos.CENTER);

for (int i =0;i<12;i++) {


double angle = Math.toRadians(i*30-90);
double inner = CLOCK_RADIUS-20;
double outer = CLOCK_RADIUS-5;

double x1 = CLOCK_CENTER_X + inner * Math.cos(angle);


double y1 = CLOCK_CENTER_Y + inner * Math.sin(angle);
double x2 = CLOCK_CENTER_X + outer * Math.cos(angle);
double y2 = CLOCK_CENTER_Y + outer * Math.sin(angle);

gc.setStroke(Color.web("#333333"));
gc.setLineWidth(i%3 == 0 ? 4 : 2);
gc.strokeLine(x1, y1, x2, y2);

}
gc.setFill(Color.GRAY);
gc.setFont(Font.font("Segoe UI",FontWeight.BOLD,18));
for (int i =1; i<=12;i++) {
double angle = Math.toRadians(i*30-90);
double distanceFromCenter = CLOCK_RADIUS-35;
double x = CLOCK_CENTER_X+distanceFromCenter*Math.cos(angle);
double y = CLOCK_CENTER_Y+distanceFromCenter*Math.sin(angle);
gc.fillText(String.valueOf(i),x-5,y+5);
}

LocalTime now = LocalTime.now();

// ‫حساب زوايا العقارب‬


double secondAngle = now.getSecond() * 6;// ‫ درجات‬6 ‫لكل ثانية‬
double minuteAngle = now.getMinute() * 6 +now.getSecond() * 0.1;
double hourAngle = (now.getHour() %12) * 30 + now.getMinute() * 0.5;
// ‫رسم العقارب‬
drawHand(gc,hourAngle,CLOCK_RADIUS*0.5,6);
drawHand(gc,minuteAngle,CLOCK_RADIUS*0.75,4);
// gc.setStroke(Color.RED);
drawHand(gc,secondAngle,CLOCK_RADIUS*0.9,1);// ‫عقرب الثواني‬
// ‫عقرب الدقائق‬
// ‫عقرب الساعات‬
// ‫رسم مركز الساعة‬
gc.setFill(Color.web("#333333"));
gc.fillOval(CLOCK_CENTER_X-5,CLOCK_CENTER_Y-5,10,10);

}
private void drawHand(GraphicsContext gc,double angleDeg,double length,double width) {
double rad = Math.toRadians( angleDeg - 90);
double x2 = CLOCK_CENTER_X + length*Math.cos(rad);
double y2 = CLOCK_CENTER_Y + length*Math.sin(rad);

gc.setStroke(Color.web("333333"));
gc.setLineWidth(width);

gc.strokeLine(CLOCK_CENTER_X,CLOCK_CENTER_Y,x2,y2);
}
private HBox createDateBox() {
HBox dateBox =new HBox(5);
dateBox.setAlignment(Pos.CENTER);
dateBox.getStyleClass().add("date-box");

Label dayLabel = new Label();


dayLabel.getStyleClass().add("date-day-label");
dayLabel.setPadding(new Insets(0));

Label dateLabel = new Label();


dateLabel.getStyleClass().add("date-label");
dateLabel.setPadding(new Insets(0));

Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1),event -> {


LocalDate today = LocalDate.now();
String[] arabicDays = {"‫"اال‬,"‫"الثالثاء‬,"‫"األريعاء‬,"‫"الخميس‬,"‫"الجمعة‬,"‫"السبت‬,"‫األحد‬
‫;}"ثنين‬
dayLabel.setText(arabicDays[today.getDayOfWeek().getValue()-1]);
dateLabel.setText(today.toString());

}));
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
dateBox.getChildren().addAll(dateLabel,dayLabel);
return dateBox;
}
public static void main(String[] args) {
launch(args);
} }

Class 4 :

package AirportSystem;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.Stage;

public class enteraflights extends Application {

public static void main(String[] args) {


launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("✈️ Flight Registration Form");

// ‫قائمة المدن مع البحث‬


ObservableList<String> cities = FXCollections.observableArrayList(
"Cairo", "London", "Paris", "Tokyo", "New York", "Berlin", "Dubai",
"Moscow", "Madrid", "Beijing", "Rome"
);

// ========= ‫ ========= الحقول‬//


TextField flightNumber = new TextField("1");
flightNumber.focusedProperty().addListener(((observable, oldValue, newValue) -> {
if (newValue)
flightNumber.selectAll();
}));
DatePicker flightDate = new DatePicker();
TextField flightTime = new TextField();

TextField planeNumber = new TextField();


TextField planeName = new TextField();
TextField captainName = new TextField();

ComboBox<String> departureBox = createSearchableComboBox(cities);


ComboBox<String> destinationBox = createSearchableComboBox(cities);

TextField seatCount = new TextField();


TextField passengerCount = new TextField("0");
passengerCount.focusedProperty().addListener(((observable, oldValue, newValue) -> {
if (newValue)
flightNumber.selectAll();
}));

// ========= ‫ ========= األقسام‬//


// Flight Info Section
// Flight Info Section as a staircase layout
VBox flightInfoStair = new VBox(15);
flightInfoStair.setPadding(new Insets(10));

HBox row1 = new HBox(10);


Label lbl1 = new Label("✈️ Flight Number:");
lbl1.setMinWidth(150);
flightNumber.setPrefWidth(200);
row1.getChildren().addAll(lbl1, flightNumber);
row1.setPadding(new Insets(0, 0, 0, 0));

HBox row2 = new HBox(10);


Label lbl2 = new Label("📅 Flight Date:");
lbl2.setMinWidth(150);
flightDate.setPrefWidth(200);
row2.getChildren().addAll(lbl2, flightDate);
row2.setPadding(new Insets(0, 0, 0, 50));

HBox row3 = new HBox(10);


Label lbl3 = new Label("⏰ Flight Time:");
lbl3.setMinWidth(150);
flightTime.setPrefWidth(200);
row3.getChildren().addAll(lbl3, flightTime);
row3.setPadding(new Insets(0, 0, 0, 100));

flightInfoStair.getChildren().addAll(row1, row2, row3);

/////////////////////////////////////
VBox planeInfoStair = new VBox(15);
planeInfoStair.setPadding(new Insets(10));

HBox planeRow1 = new HBox(10);


Label pl = new Label(" Plane Number:");
pl.setMinWidth(150);
planeNumber.setPrefWidth(200);
planeRow1.getChildren().addAll(pl, planeNumber);
planeRow1.setPadding(new Insets(0, 0, 0, 0));

HBox planeRow2 = new HBox(10);


Label p2 = new Label("✈️ Plane Name:");
p2.setMinWidth(150);
planeName.setPrefWidth(200);
planeRow2.getChildren().addAll(p2, planeName);
planeRow2.setPadding(new Insets(0, 0, 0, 50));

HBox planeRow3 = new HBox(10);


Label p3 = new Label("️ Captain Name:");
p3.setMinWidth(150);
captainName.setPrefWidth(200);
planeRow3.getChildren().addAll(p3, captainName);
planeRow3.setPadding(new Insets(0, 0, 0, 100));

planeInfoStair.getChildren().addAll(planeRow1, planeRow2, planeRow3);

/////////////////////////////////////////////////

//////////
VBox passengerInfoStear = new VBox(15);
passengerInfoStear.setPadding(new Insets(10));

HBox passRow1 = new HBox(10);


Label departLabel = new Label(" Departure City:");
departLabel.setMinWidth(150);
departureBox.setPrefWidth(200);
passRow1.getChildren().addAll(departLabel, departureBox); // ‫تم ( هنا كان الخطأ‬
‫ استخدام‬pl ‫ و‬planeNumber ‫ بدًال من‬departLabel ‫ و‬departureBox)
passRow1.setPadding(new Insets(0, 0, 0, 0));

HBox passRow2 = new HBox(10);


Label destLabel = new Label("🛬 Destination City:");
destLabel.setMinWidth(150);
destinationBox.setPrefWidth(200);
passRow2.getChildren().addAll(destLabel, destinationBox); // ‫تم ( هنا كان الخطأ‬
‫ استخدام‬p2 ‫ و‬planeName ‫ بدًال من‬destLabel ‫ و‬destinationBox)
passRow2.setPadding(new Insets(0, 0, 0, 50));

HBox passRow3 = new HBox(10);


Label seatLabel = new Label("💺 Seats Number:");
seatLabel.setMinWidth(150);
seatCount.setPrefWidth(200);
passRow3.getChildren().addAll(seatLabel, seatCount); // ‫تم استخدام( هنا كان الخطأ‬
p3 ‫ و‬captainName ‫ بدًال من‬seatLabel ‫ و‬seatCount)
passRow3.setPadding(new Insets(0, 0, 0, 100));

HBox passRow4 = new HBox(10);


Label passLabel = new Label("🧍 Passengers Number:");
passLabel.setMinWidth(150);
passengerCount.setPrefWidth(200);
passRow4.getChildren().addAll(passLabel, passengerCount); // ‫تم ( هنا كان الخطأ‬
‫ استخدام‬p3 ‫ و‬captainName ‫ بدًال من‬passLabel ‫ و‬passengerCount)
passRow4.setPadding(new Insets(0, 0, 0, 100));

passengerInfoStear.getChildren().addAll(passRow1, passRow2, passRow3, passRow4);

// ========= ‫ ========= زر الحفظ‬//


// ... (‫)الكود السابق يبقى كما هو حتى جزء األزرار‬

// ========= ‫ ========= األزرار‬//


// ========= ‫ ========= زر الحفظ‬//
Button saveButton = new Button("💾 Save");
saveButton.setStyle("-fx-font-size: 18px; -fx-background-color: #4CAF50; -fx-text-
fill: white;");
saveButton.setOnAction(e -> {
try {
// ‫التحقق من أن الحقول ليست فارغة‬
if (flightNumber.getText().isEmpty() || flightDate.getValue() == null ||
flightTime.getText().isEmpty() || planeNumber.getText().isEmpty()
||
planeName.getText().isEmpty() || captainName.getText().isEmpty() ||
departureBox.getValue() == null || destinationBox.getValue() ==
null ||
seatCount.getText().isEmpty() ||
passengerCount.getText().isEmpty()) {

Alert alert = new Alert(Alert.AlertType.ERROR);


alert.setTitle("Error");
alert.setHeaderText("Missing Information");
alert.setContentText("Please fill all required fields!");
alert.showAndWait();
return;
}

// ‫التحقق من أن عدد المقاعد وعدد المسافرين أرقام صحيحة‬


int seats = Integer.parseInt(seatCount.getText());
int passengers = Integer.parseInt(passengerCount.getText());

// ‫التحقق من أن عدد المسافرين ال يتجاوز عدد المقاعد‬


if (passengers > seats) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("Invalid Passenger Count");
alert.setContentText("Number of passengers cannot exceed number of
seats!\n"
+ "Available seats: " + seats + "\n"
+ "Entered passengers: " + passengers);
alert.showAndWait();
return;
}

// ‫التحقق من أن القيم موجبة‬


if (seats <= 0 || passengers < 0) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("Invalid Values");
alert.setContentText("Seats and passengers count must be positive
numbers!");
alert.showAndWait();
return;
}

String dataSummary =
"Flight #: " + flightNumber.getText() + "\n" +
"Date: " + flightDate.getValue() + "\n" +
"Time: " + flightTime.getText() + "\n" +
"Plane #: " + planeNumber.getText() + "\n" +
"Plane Name: " + planeName.getText() + "\n" +
"Captain: " + captainName.getText() + "\n" +
"From: " + departureBox.getValue() + "\n" +
"To: " + destinationBox.getValue() + "\n" +
"Seats: " + seats + "\n" +
"Passengers: " + passengers;

Alert confirm = new Alert(Alert.AlertType.CONFIRMATION);


confirm.setTitle("Confirm Save");
confirm.setHeaderText("Are you sure you want to save this data?");
confirm.setContentText(dataSummary);

confirm.showAndWait().ifPresent(response -> {
if (response == ButtonType.OK) {
Alert success = new Alert(Alert.AlertType.INFORMATION);
success.setTitle("Success");
success.setHeaderText(null);
success.setContentText("Flight saved successfully!");
success.showAndWait();
}
});

} catch (NumberFormatException ex) {


Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("Invalid Number Format");
alert.setContentText("Please enter valid numbers for seats and passengers
count!");
alert.showAndWait();
}
});

// ‫زر الخروج الجديد‬


Button exitButton = new Button("🚪 Exit to Main");
exitButton.setStyle("-fx-font-size: 18px; -fx-background-color: #f44336; -fx-text-
fill: white;");
exitButton.setOnAction(e -> {
// ‫إغالق النافذة الحالية‬
((Stage) exitButton.getScene().getWindow()).close();

// ‫هنا يمكنك فتح الواجهة الرئيسية إذا كنت بحاجة لذلك‬


// new MainWindow().start(new Stage());
});

// ‫ إنشاء‬HBox ‫لتجميع األزرار بجانب بعضها‬


HBox buttonsBox = new HBox(20); // ‫ بين األزرار‬20 ‫مسافة‬
buttonsBox.setAlignment(Pos.CENTER);
buttonsBox.getChildren().addAll(saveButton, exitButton);

VBox root = new VBox(30,


new TitledPane("Flight Info", flightInfoStair),
new TitledPane("Plane Info", planeInfoStair),
new TitledPane("Passenger & Route Info", passengerInfoStear),
buttonsBox // ‫ استبدلنا‬saveButton ‫ بـ‬buttonsBox
);

root.setPadding(new Insets(40));
root.setAlignment(Pos.TOP_LEFT);

ScrollPane scroll = new ScrollPane(root);


scroll.setFitToWidth(true);

Scene scene = new Scene(scroll, 1800, 950);


primaryStage.setScene(scene);
primaryStage.show();
}

// ... (‫)بقية الكود يبقى كما هو‬

// ‫ إنشاء‬GridPane ‫موحد‬
private GridPane createGridPane() {
GridPane grid = new GridPane();
grid.setHgap(25);
grid.setVgap(20);
grid.setPadding(new Insets(20));
grid.setAlignment(Pos.TOP_LEFT);
ColumnConstraints col1 = new ColumnConstraints();
col1.setPercentWidth(25);
ColumnConstraints col2 = new ColumnConstraints();
col2.setPercentWidth(75);
grid.getColumnConstraints().addAll(col1, col2);
return grid;
}

// ‫قائمة منسدلة تدعم البحث الجزئي‬


private ComboBox<String> createSearchableComboBox(ObservableList<String> items) {
ComboBox<String> comboBox = new ComboBox<>();
comboBox.setEditable(true);
FilteredList<String> filtered = new FilteredList<>(items, p -> true);

comboBox.setItems(filtered);
comboBox.getEditor().textProperty().addListener((obs, oldVal, newVal) -> {
final String filter = newVal.toLowerCase();
filtered.setPredicate(item -> item.toLowerCase().contains(filter));
});

comboBox.setOnAction(e -> {
String selected= comboBox.getSelectionModel().getSelectedItem();
if (selected != null)
comboBox.getEditor().setText(selected);
});

return comboBox;

}
}
Class 5:

package AirportSystem;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.*;
import javafx.stage.Stage;

public class flaylist extends Application {

private TableView<Flight> table;


private ObservableList<Flight> flights;

public static void main(String[] args) {


launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("✈️ Flight Management System");

// Create table with full width columns


table = new TableView<>();
table.setColumnResizePolicy(TableView.UNCONSTRAINED_RESIZE_POLICY);

flights = createSampleData();
table.setItems(flights);

// Create expanded table columns


createTableColumns();

// Create larger buttons


Button refreshBtn = new Button("🔄 Refresh Flights");
refreshBtn.getStyleClass().add("refresh-btn");
refreshBtn.setOnAction(e -> refreshData());

Button closeBtn = new Button("❌ Exit System");


closeBtn.getStyleClass().add("close-btn");
closeBtn.setOnAction(e -> primaryStage.close());

// Button container with more space


HBox buttonContainer = new HBox(40, refreshBtn, closeBtn);
buttonContainer.getStyleClass().add("button-container");
buttonContainer.setAlignment(Pos.CENTER);

// Main layout with table filling available space


BorderPane root = new BorderPane();
root.setCenter(table);

// Add spacer to push buttons higher


Region spacer = new Region();
spacer.setPrefHeight(50);
VBox bottomContainer = new VBox(spacer, buttonContainer);
root.setBottom(bottomContainer);

Scene scene = new Scene(root, 1800, 950);

scene.getStylesheets().add(getClass().getResource("flaylistStyle.css").toExternalForm());

// Bind table size to window size


table.prefHeightProperty().bind(scene.heightProperty().subtract(200));
table.prefWidthProperty().bind(scene.widthProperty().subtract(40));

primaryStage.setScene(scene);
primaryStage.show();
}

private void createTableColumns() {


table.getColumns().clear();

// )‫ بكسل للمسافات الجانبية‬40 ‫حساب العرض المتاح (نطرح‬


double availableWidth = 1800 - 100;

// ‫إنشاء األعمدة مع تحديد عرض نسبي‬


TableColumn<Flight, String> flightNumberCol = createColumn("Flight Code",
"flightNumber", availableWidth * 0.08);
TableColumn<Flight, String> dateCol = createColumn("Date", "date", availableWidth *
0.10);
TableColumn<Flight, String> timeCol = createColumn("Time", "time", availableWidth *
0.10);
TableColumn<Flight, String> planeNumberCol = createColumn("Plane Code",
"planeNumber", availableWidth * 0.10);
TableColumn<Flight, String> planeNameCol = createColumn("Plane Name", "planeName",
availableWidth * 0.10);
TableColumn<Flight, String> captainCol = createColumn("Captain", "captain",
availableWidth * 0.10);
TableColumn<Flight, String> departureCol = createColumn("Departure", "departure",
availableWidth * 0.10);
TableColumn<Flight, String> destinationCol = createColumn("Destination",
"destination", availableWidth * 0.10);

TableColumn<Flight, Integer> seatsCol = createNumberColumn("Seats", "seats",


availableWidth * 0.07);
TableColumn<Flight, Integer> passengersCol = createNumberColumn("Passengers",
"passengers", availableWidth * 0.09);

TableColumn<Flight, Void> actionsCol = createActionsColumn("Actions",


availableWidth * 0.10);

table.getColumns().addAll(
flightNumberCol, dateCol, timeCol,
planeNumberCol, planeNameCol, captainCol,
departureCol, destinationCol,
seatsCol, passengersCol, actionsCol
);
}
private TableColumn<Flight, String> createColumn(String title, String property, double
width) {
TableColumn<Flight, String> col = new TableColumn<>(title);
col.setCellValueFactory(new PropertyValueFactory<>(property));
col.setPrefWidth(width);
col.setMinWidth(width * 0.8); // ‫حد أدنى للعرض‬
col.setStyle("-fx-alignment: CENTER; -fx-border-color: #e0e0e0; -fx-border-width: 1
1 1 1;");
return col;
}

private TableColumn<Flight, Integer> createNumberColumn(String title, String property,


double width) {
TableColumn<Flight, Integer> col = new TableColumn<>(title);
col.setCellValueFactory(new PropertyValueFactory<>(property));
col.setPrefWidth(width);
col.setStyle("-fx-alignment: CENTER; -fx-border-color: #e0e0e0; -fx-border-width: 1
1 1 1;");
return col;
}

private TableColumn<Flight, Void> createActionsColumn(String title, double width) {


TableColumn<Flight, Void> col = new TableColumn<>(title);
col.setPrefWidth(width);
col.setStyle("-fx-border-color: #e0e0e0; -fx-border-width: 0 0 0 0;");

col.setCellFactory(param -> new TableCell<Flight, Void>() {


private final Button btn = new Button("View");

{
btn.getStyleClass().add("view-btn");
btn.setMaxWidth(Double.MAX_VALUE);
btn.setOnAction(e -> {
Flight flight = getTableView().getItems().get(getIndex());
if (flight != null) openReservationsView(flight);
});
}

@Override
protected void updateItem(Void item, boolean empty) {
super.updateItem(item, empty);
setGraphic(empty ? null : btn);
}
});

return col;
}

// ‫دالة مساعدة لألعمدة النصية‬

// ‫باقي الدوال تبقى كما هي بدون تغيير‬

private void refreshData() {


flights.clear();
flights.addAll(createSampleData());

Alert alert = new Alert(Alert.AlertType.INFORMATION);


alert.setTitle("Data Updated");
alert.setHeaderText(null);
alert.setContentText("Flight data has been refreshed successfully");
alert.showAndWait();
}
private void openReservationsView(Flight flight) {
try {
if (flight != null) { // ‫ التحقق من أن الرحلة غير‬null
tecketlist reservationsView = new tecketlist(flight);
Stage stage = new Stage();
stage.setTitle("Flight Reservations - " + flight.getFlightNumber());
reservationsView.start(stage); // ‫ تأكد من تمرير‬Stage ‫صالح‬
} else {
showErrorAlert("No flight selected");
}
} catch (Exception e) {
showErrorAlert("Failed to open reservations: " + e.getMessage());
}
}

private void showErrorAlert(String message) {


Alert error = new Alert(Alert.AlertType.ERROR);
error.setTitle("Error");
error.setHeaderText(null);
error.setContentText(message);
error.showAndWait();
}

private ObservableList<Flight> createSampleData() {


ObservableList<Flight> flights = FXCollections.observableArrayList();

flights.add(new Flight("FL101", "2023-05-15", "08:00",


"BOEING-737", "Boeing 737", "Capt. Smith",
"Cairo", "London", 180, 150));
flights.add(new Flight("FL202", "2023-05-15", "10:30",
"AIRBUS-320", "Airbus A320", "Capt. Johnson",
"Paris", "New York", 220, 210));

return flights;
}

public static class Flight {


private final String flightNumber;
private final String date;
private final String time;
private final String planeNumber;
private final String planeName;
private final String captain;
private final String departure;
private final String destination;
private final int seats;
private final int passengers;

public Flight(String flightNumber, String date, String time,


String planeNumber, String planeName, String captain,
String departure, String destination,
int seats, int passengers) {
this.flightNumber = flightNumber;
this.date = date;
this.time = time;
this.planeNumber = planeNumber;
this.planeName = planeName;
this.captain = captain;
this.departure = departure;
this.destination = destination;
this.seats = seats;
this.passengers = passengers;
}
// Getters for all properties
public String getFlightNumber() { return flightNumber; }
public String getDate() { return date; }
public String getTime() { return time; }
public String getPlaneNumber() { return planeNumber; }
public String getPlaneName() { return planeName; }
public String getCaptain() { return captain; }
public String getDeparture() { return departure; }
public String getDestination() { return destination; }
public int getSeats() { return seats; }
public int getPassengers() { return passengers; }
}
}
Class 6:

package AirportSystem;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

import java.text.DateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class TicketDepartment extends Application {


@Override

public void start(Stage primaryStage) {

GridPane gridPane = new GridPane();

// ColumnConstrains ‫تحديد قيود لألعمدة‬


ColumnConstraints col1 = new ColumnConstraints(200);// ‫بكسل‬100 ‫عرض العمود‬
ColumnConstraints col2 = new ColumnConstraints(220);// ‫بكسل‬120 ‫عرض العمود‬
ColumnConstraints col3 = new ColumnConstraints(180);//‫بكسل‬130 ‫عرض العمود‬
ColumnConstraints col4 = new ColumnConstraints(180);// ‫ بكسل‬140‫عرض العمود‬
ColumnConstraints col5 = new ColumnConstraints(220);// ‫ بكسل‬120 ‫عرض العمود‬

gridPane.getColumnConstraints().addAll(col1,col2,col3,col4,col5);// ‫اضافتهم للحاوية‬

gridPane.setId("graid-pane-container");
Label newTicket = new Label("New Ticket");
newTicket.setId("new-ticket");

// ‫ايقونةجواز السفر تحميلها‬


Image passportIcon = new
Image(getClass().getResourceAsStream("Pictures/0003.jpg"));
ImageView passportIconView = new ImageView(passportIcon);
passportIconView.setFitWidth(70);// ‫عرض االيقونة‬
passportIconView.setFitHeight(50);// ‫ارتفاع االيقونة‬
Label passportData = new Label("PASSPORT DATA ");
passportData.setGraphic(passportIconView);
passportData.setContentDisplay(ContentDisplay.RIGHT);
passportData.setUnderline(true);
passportData.setId("passport-data");

Label passengerID = new Label("Passenger ID");


TextField passengerIDField = new TextField();
passengerIDField.getStyleClass().add("text-field-small");
passengerIDField.setPromptText("Passenger ID");

Label passportNo = new Label("Passport No:");


TextField passportNoField = new TextField();
passportNoField.getStyleClass().add("text-field-small");
passportNoField.setPromptText("Enter Passport No");

Label passengerName = new Label("Name :");


TextField passengerNameField = new TextField();
passengerNameField.setPromptText("Enter The Name");

Label passengerFatherName = new Label("Middle Name :");


TextField passengerFatherNameField = new TextField();
passengerFatherNameField.setPromptText("Enter Middle Name");

Label passengerGrandName = new Label("GrandFather Name :");


TextField passengerGrandNameField = new TextField();
passengerGrandNameField.setPromptText("Enter Grand Name");

Label surname = new Label("Surname :");


TextField surnameField = new TextField();
surnameField.setPromptText("Enter Surname");

Label passengerGender = new Label("Gender :");


ComboBox<String> genderMenu = new ComboBox<>();
genderMenu.getItems().addAll("Male","Female");
genderMenu.setEditable(true);

genderMenu.setPromptText("Select Gender");

Label passengerBirth = new Label("BirthYear :");


TextField passengerBirthField = new TextField();
passengerBirthField.getStyleClass().add("text-field-small");
passengerBirthField.setPromptText("Enter BirthYear");

Label passengerAge = new Label("Age :");


TextField passengerAgeField = new TextField();
passengerBirthField.textProperty().addListener(((observable, oldValue, newValue) ->
{
try {
int birthYear = Integer.parseInt(newValue.trim());
int currentYear = LocalDate.now().getYear();
int age = currentYear - birthYear;
if (age >=0 && age<=150) {
passengerAgeField.setText(String.valueOf(age));
} else {
passengerAgeField.setText("");
}
} catch (NumberFormatException e) {
passengerAgeField.setText("");
}
}));
passengerAgeField.getStyleClass().add("text-field-small");
passengerAgeField.setPromptText("Enter Age");

Label passengerCountry = new Label("Country of Birth :");


ObservableList<String> countriesList = FXCollections.observableArrayList(
"USA","England","Russia","France", "Turkey"
,"Spain","Germany","Italy","Japan","Brazil","China","India","Canada","Australia"
,"Mexico","South Africa","Egypt","Saudi Arabia","South Korea","Argintina"
,"Thailand","Afghanistan","Algeria","Bahrain","Bangladesh","Cameroon","Republic
of Congo"
,"Denmark","Iran","Iraq","Indonesia","Jordan","kwait","Lebanon","Malaysia","Moro
cco"
,"New
Zealand","Oman","Qatar","Romania","Sudan","Syria","Tunisia","UAE","Venezuela",
"Vietnam","Yemen","Zambia","Zimbabwe");

ComboBox<String> countries = new ComboBox<>();


countries.setPromptText("Please Choose");
countries.setEditable(true);
FilteredList<String> filteredCountryList = new FilteredList<>(countriesList,P ->
true);
countries.setItems(filteredCountryList);
countries.getEditor().textProperty().addListener((observable, oldValue, newValue) -
> {
filteredCountryList.setPredicate(country-> {
if (newValue==null || newValue.isEmpty()) {
return true;
}
return country.toLowerCase().contains(newValue.toLowerCase());
});
countries.hide();
countries.setItems(FXCollections.observableArrayList(filteredCountryList));
countries.show();

});

Label passengerNationality = new Label("Nationality :");


ComboBox<String> passengerNationalityMenu = new ComboBox<>();
ObservableList<String> NationalityList = FXCollections.observableArrayList(
"USA","England","Russia","France", "Turkey"
,"Spain","Germany","Italy","Japan","Brazil","China","India","Canada","Austr
alia"
,"Mexico","South Africa","Egypt","Saudi Arabia","South Korea","Argintina"
,"Thailand","Afghanistan","Algeria","Bahrain","Bangladesh","Cameroon","Repu
blic of Congo"
,"Denmark","Iran","Iraq","Indonesia","Jordan","kwait","Lebanon","Malaysia",
"Morocco"
,"New
Zealand","Oman","Qatar","Romania","Sudan","Syria","Tunisia","UAE","Venezuela",
"Vietnam","Yemen","Zambia","Zimbabwe"
);
passengerNationalityMenu.setEditable(true);
FilteredList<String> filteredNationalityList = new
FilteredList<>(NationalityList,P-> true);
passengerNationalityMenu.setItems(filteredNationalityList);
passengerNationalityMenu.getEditor().textProperty().addListener((observable,
oldValue, newValue) -> {
filteredNationalityList.setPredicate(item-> {
if (newValue==null || newValue.isEmpty()) {
return true;
}
return item.toLowerCase().contains(newValue.toLowerCase());
});
passengerNationalityMenu.hide();

passengerNationalityMenu.setItems(FXCollections.observableArrayList(filteredNationalityList
));
passengerNationalityMenu.show();
});
Label passportDateISS = new Label("Date of Issue :");
TextField passportDateISSField = new TextField();
passportDateISSField.setPromptText("Select Date");
DatePicker dateofISSPassport = new DatePicker();
dateofISSPassport.setVisible(false);
passportDateISSField.setOnMouseClicked(event -> dateofISSPassport.show());

dateofISSPassport.setOnAction(event -> {
LocalDate selectionDate = dateofISSPassport.getValue();
if (selectionDate != null) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = selectionDate.format(formatter);
passportDateISSField.setText(formattedDate);
}

});

Label passportDateEX = new Label("Date of Ex :");


TextField passportDateEXField = new TextField();
passportDateEXField.setPromptText("Select Date");
DatePicker dateofEXPassport = new DatePicker();
dateofEXPassport.setVisible(false);
passportDateEXField.setOnMouseClicked(event -> dateofEXPassport.show());

dateofEXPassport.setOnAction(event -> {
LocalDate selectionDate = dateofEXPassport.getValue();
if (selectionDate != null) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = selectionDate.format(formatter);
passportDateEXField.setText(formattedDate);
}

});

Image travelDataIcon = new


Image(getClass().getResourceAsStream("Pictures/0004.PNG"));
ImageView travelDataIconView = new ImageView(travelDataIcon);
travelDataIconView.setFitWidth(40);// ‫عرض االيقونة‬
travelDataIconView.setFitHeight(30);// ‫ارتفاع االيقونة‬
Label travelData = new Label("TRAVEL DATA ");
travelData.setGraphic(travelDataIconView);
travelData.setContentDisplay(ContentDisplay.RIGHT);
travelData.setUnderline(true);
travelData.setId("travel-data");

Label travelCode = new Label("Travel Code:");


TextField trvelCodeField = new TextField();
trvelCodeField.getStyleClass().add("text-field-small");
trvelCodeField.setPromptText("Please Enter Travel Code");

ObservableList<String> arabAirports = FXCollections.observableArrayList(


"Sanaa Airport", "Jeddah Airport", "Dubai Airport", "Abu Dhabi Airport",
"Cairo Airport",
"Doha Airport", "Kuwait Airport", "Beirut Airport", "Baghdad Airport",
"Amman Airport",
"Algiers Airport", "Tunis-Carthage Airport", "Mohammed V Airport -
Morocco", "Khartoum Airport",
"Damascus Airport", "Tripoli Airport", "Manama Airport", "Muscat Airport",
"Riyadh Airport"
);

Label travelFrom = new Label("Travel From:");


ComboBox<String> travelFromField = new ComboBox<>();
FilteredList<String> filteredFromList = new FilteredList<>(arabAirports, p ->
true);
travelFromField.setItems(filteredFromList);
travelFromField.setEditable(true);
travelFromField.setPromptText("Sanaa Airport"); // Default value

travelFromField.getEditor().textProperty().addListener((obs, oldText, newText) -> {


filteredFromList.setPredicate(item ->
item.toLowerCase().contains(newText.toLowerCase()));
travelFromField.hide();
travelFromField.setItems(FXCollections.observableArrayList(filteredFromList));
travelFromField.show();
});

Label travelTo = new Label("Travel To:");

ComboBox<String> travelToField = new ComboBox<>();


FilteredList<String> filteredToList = new FilteredList<>(arabAirports, p -> true);
travelToField.setItems(filteredToList);
travelToField.setEditable(true);
//travelToField.setValue("Sanaa Airport"); // Default value
travelToField.getEditor().textProperty().addListener((obs, oldText, newText) -> {
filteredToList.setPredicate(item ->
item.toLowerCase().contains(newText.toLowerCase()));
travelToField.hide();
travelToField.setItems(FXCollections.observableArrayList(filteredToList));
travelToField.show();
});

Image ticketDataIcon = new


Image(getClass().getResourceAsStream("Pictures/0001.PNG"));
ImageView ticketDataIconView = new ImageView(ticketDataIcon);
ticketDataIconView.setFitWidth(40);// ‫عرض االيقونة‬
ticketDataIconView.setFitHeight(30);// ‫ارتفاع االيقونة‬
Label ticketData = new Label("TICKET DATA ");
ticketData.setGraphic(ticketDataIconView);
ticketData.setContentDisplay(ContentDisplay.RIGHT);
ticketData.setUnderline(true);
ticketData.setId("ticket-data");

//Label ticketData = new Label("TICKET DATA");


// ticketData.setId("ticket-data");

Label ticketCode = new Label("Ticket Code:");


TextField ticketCodeField = new TextField();
ticketCodeField.getStyleClass().add("text-field-small");
ticketCodeField.setPromptText("Enter Ticket Code");
Label ticketPrice = new Label("Ticket Price:");
TextField ticketPriceField = new TextField();
ticketPriceField.getStyleClass().add("text-field-small");
ticketPriceField.setPromptText("Ticket Price");

Button cancelButton = new Button("Cancel");


Button submitButton = new Button("Submit");
submitButton.setOnAction(event -> {
try {
Passenger newPassenger = new Passenger(passengerIDField.getText(),
passportNoField.getText(),passengerNameField.getText(),
passengerNationalityMenu.getValue(),passengerBirthField.getText(),

travelFromField.getEditor().getText(),travelToField.getEditor().getText(),ticketCodeField.g
etText(),
Double.parseDouble(ticketPriceField.getText()));
DatabaseHandler.addPassenger(newPassenger);
Alert successAlert = new Alert(Alert.AlertType.INFORMATION);
successAlert.setTitle("Success");
successAlert.setHeaderText("Success Opreation");
successAlert.setContentText("passenger added seccussfully");
successAlert.showAndWait();

System.out.println("");
} catch (NumberFormatException e) {
Alert errorAlert = new Alert(Alert.AlertType.ERROR);
errorAlert.setTitle("Invalid Ticket Price");
errorAlert.setHeaderText(null);
errorAlert.setContentText("Please enter a valid numeric ticket price.");
errorAlert.showAndWait();
}

});

gridPane.add(newTicket,2,0,2,1);
gridPane.add(passportData,0,1,4,1);

gridPane.add(passengerID,0,2);
gridPane.add(passengerIDField,0,3);

gridPane.add(passportNo,1,2);
gridPane.add(passportNoField,1,3);

gridPane.add(passengerName,2,2);
gridPane.add(passengerNameField,2,3);

gridPane.add(passengerFatherName,3,2);
gridPane.add(passengerFatherNameField,3,3);

gridPane.add(passengerGrandName,4,2);
gridPane.add(passengerGrandNameField,4,3);

gridPane.add(surname,0,4);
gridPane.add(surnameField ,0,5);
gridPane.add(passengerGender,1,4);
gridPane.add(genderMenu,1,5);

gridPane.add(passengerBirth,2,4);
gridPane.add(passengerBirthField,2,5);

gridPane.add(passengerAge,3,4);
gridPane.add(passengerAgeField,3,5);

gridPane.add(passengerCountry,4,4);
gridPane.add(countries,4,5);

gridPane.add(passengerNationality,0,6);
gridPane.add(passengerNationalityMenu,0,7);

gridPane.add(passportDateISS,1,6);
gridPane.add(passportDateISSField,1,7);
gridPane.add(dateofISSPassport,1,7);

gridPane.add(passportDateEX,2,6);
gridPane.add(passportDateEXField,2,7);
gridPane.add(dateofEXPassport,2,7);

gridPane.add(travelData,0,8,3,1);

gridPane.add(travelCode,0,9);
gridPane.add(trvelCodeField,0,10);

gridPane.add(travelFrom,1,9);
gridPane.add(travelFromField,1,10);

gridPane.add(travelTo,2,9);
gridPane.add(travelToField,2,10);

gridPane.add(ticketData,0,11,2,1);

gridPane.add(ticketCode,0,12);
gridPane.add(ticketCodeField,0,13);

gridPane.add(ticketPrice,1,12);
gridPane.add(ticketPriceField,1,13);

gridPane.add(cancelButton,1,15);
gridPane.add(submitButton,3,15);

gridPane.setAlignment(Pos.CENTER);
gridPane.setVgap(10);
gridPane.setHgap(10);

Scene scene = new Scene(gridPane,1800,950);

scene.getStylesheets().add(getClass().getResource("ticketStyle.css").toExternalForm());
primaryStage.setTitle("TICKET");
primaryStage.setScene(scene);
primaryStage.show();

}
public static void main(String[] args) {
launch(args);
}
}
Class 6:

package AirportSystem;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.*;
import javafx.stage.Stage;

public class tecketlist extends Application {

private final flaylist.Flight selectedFlight;

public tecketlist(flaylist.Flight selectedFlight) {


this.selectedFlight = selectedFlight;
}

@Override
public void start(Stage primaryStage) {
try {
// ‫ التحقق من أن‬selectedFlight ‫ غير‬null
if (selectedFlight == null) {
throw new IllegalStateException("Flight data is not available");
}

primaryStage.setTitle("Flight Reservations - " +


selectedFlight.getFlightNumber());

VBox flightInfoBox = createFlightInfoSection();


Separator separator = new Separator();
separator.setMaxWidth(Double.MAX_VALUE);

Label reservationsTitle = new Label("Flight Reservations");


reservationsTitle.setStyle("-fx-font-size: 16px; -fx-font-weight: bold;");

TableView<Reservation> reservationsTable = new TableView<>();


setupReservationsTable(reservationsTable);

// ‫زر العودة إلى الواجهة الرئيسية‬


Button backButton = new Button("← Back to Flights");
backButton.setStyle("-fx-font-size: 14px; -fx-background-color: #607D8B; -fx-
text-fill: white;");
backButton.setOnAction(e -> primaryStage.close());

Button addReservationBtn = new Button("➕ Add New Reservation");


addReservationBtn.setStyle("-fx-font-size: 14px; -fx-background-color: #4CAF50;
-fx-text-fill: white;");
addReservationBtn.setOnAction(e -> showAddReservationDialog());

HBox buttonsBox = new HBox(10, backButton, addReservationBtn);


buttonsBox.setAlignment(Pos.CENTER_LEFT);
buttonsBox.setPadding(new Insets(10, 0, 0, 0));

VBox mainLayout = new VBox(15, flightInfoBox, separator, reservationsTitle,


reservationsTable, buttonsBox);
mainLayout.setPadding(new Insets(15));

mainLayout.setStyle("-fx-background-color: #f9f9f9;");

Scene scene = new Scene(mainLayout, 1800, 950);

scene.getStylesheets().add(getClass().getResource("tecketlistStyle.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch (Exception e) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("Failed to open window");
alert.setContentText(e.getMessage());
alert.showAndWait();
}
}
private VBox createFlightInfoSection() {
Label titleLabel = new Label("Flight Information");
titleLabel.setStyle("-fx-font-size: 18px; -fx-font-weight: bold;");

// ‫ إنشاء‬GridPane ‫لمعلومات الرحلة األساسية‬


GridPane flightDetails = new GridPane();
flightDetails.setHgap(15);
flightDetails.setVgap(10);
flightDetails.setPadding(new Insets(10));

flightDetails.addRow(0, new Label("Flight Number:"), new


Label(selectedFlight.getFlightNumber()));
flightDetails.addRow(1, new Label("Date:"), new Label(selectedFlight.getDate()));
flightDetails.addRow(2, new Label("Time:"), new Label(selectedFlight.getTime()));
flightDetails.addRow(3, new Label("From:"), new
Label(selectedFlight.getDeparture()));
flightDetails.addRow(4, new Label("To:"), new
Label(selectedFlight.getDestination()));
flightDetails.getStyleClass().add("flight-details");

// ‫إنشاء مربع عدد المقاعد‬


VBox seatsBox = createInfoBox("Total Seats",
String.valueOf(selectedFlight.getSeats()), "#4CAF50");

// ‫إنشاء مربع عدد المسافرين‬


int passengerCount = getSampleReservations().size();
VBox passengersBox = createInfoBox("Passengers", String.valueOf(passengerCount),
"#2196F3");

// ‫إنشاء زر العودة‬
Button backButton = new Button("← Back");
backButton.setStyle("-fx-font-size: 14px; -fx-background-color: #607D8B; -fx-text-
fill: white;");
backButton.setOnAction(e -> ((Stage) backButton.getScene().getWindow()).close());

// ‫ وضع المربعات في‬HBox ‫جانبي‬


VBox infoBoxes = new VBox(10, seatsBox, passengersBox, backButton);
infoBoxes.setAlignment(Pos.TOP_CENTER);
infoBoxes.setPadding(new Insets(0, 0, 0, 20));

// ‫ وضع معلومات الرحلة والمربعات الجانبية في‬HBox ‫رئيسي‬


HBox mainInfoBox = new HBox(20, flightDetails, infoBoxes);
mainInfoBox.setAlignment(Pos.CENTER_LEFT);
mainInfoBox.setPadding(new Insets(10));
mainInfoBox.getStyleClass().add("info-container");

VBox flightInfoBox = new VBox(10, titleLabel, mainInfoBox);


flightInfoBox.setPadding(new Insets(15));
flightInfoBox.setStyle("-fx-background-color: #e3f2fd; -fx-border-color: #bbdefb; -
fx-border-width: 1px;");

return flightInfoBox;
}

// )‫دالة مساعدة إلنشاء المربعات المعلوماتية (كما هي‬


private VBox createInfoBox(String title, String value, String color) {
Label titleLabel = new Label(title);
titleLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 14px;");

Label valueLabel = new Label(value);


valueLabel.setStyle("-fx-font-size: 24px; -fx-font-weight: bold; -fx-text-fill: " +
color + ";");

VBox box = new VBox(5, titleLabel, valueLabel);


box.setAlignment(Pos.CENTER);
box.setPadding(new Insets(15));
box.setStyle("-fx-background-color: white; -fx-border-color: " + color + "; -fx-
border-width: 2px; -fx-border-radius: 5px;");

return box;
}
private void setupReservationsTable(TableView<Reservation> table) {
// Passenger Information Columns
TableColumn<Reservation, String> passengerIdCol = new TableColumn<>("Passenger
ID");
passengerIdCol.setCellValueFactory(new PropertyValueFactory<>("passengerId"));

TableColumn<Reservation, String> passportNoCol = new TableColumn<>("Passport No");


passportNoCol.setCellValueFactory(new PropertyValueFactory<>("passportNumber"));

// ‫عمود االسم الكامل بدًال من األعمدة المنفصلة‬


TableColumn<Reservation, String> fullNameCol = new TableColumn<>("Full Name");
fullNameCol.setCellValueFactory(cellData -> {
Reservation reservation = cellData.getValue();
// ‫دمج جميع مكونات االسم في سلسلة واحدة‬
String fullName = reservation.getPassengerName() + " " +
reservation.getFatherName() + " " +
reservation.getGrandName() + " " +
reservation.getSurname();
return new javafx.beans.property.SimpleStringProperty(fullName);
});

TableColumn<Reservation, String> genderCol = new TableColumn<>("Gender");


genderCol.setCellValueFactory(new PropertyValueFactory<>("gender"));

TableColumn<Reservation, String> birthYearCol = new TableColumn<>("Birth Year");


birthYearCol.setCellValueFactory(new PropertyValueFactory<>("birthYear"));

TableColumn<Reservation, String> ageCol = new TableColumn<>("Age");


ageCol.setCellValueFactory(new PropertyValueFactory<>("age"));

TableColumn<Reservation, String> countryCol = new TableColumn<>("Country");


countryCol.setCellValueFactory(new PropertyValueFactory<>("country"));

TableColumn<Reservation, String> nationalityCol = new TableColumn<>("Nationality");


nationalityCol.setCellValueFactory(new PropertyValueFactory<>("nationality"));

TableColumn<Reservation, String> passportIssueCol = new TableColumn<>("Passport


Issue");
passportIssueCol.setCellValueFactory(new
PropertyValueFactory<>("passportIssueDate"));

TableColumn<Reservation, String> passportExpiryCol = new TableColumn<>("Passport


Expiry");
passportExpiryCol.setCellValueFactory(new
PropertyValueFactory<>("passportExpiryDate"));

// Travel Information Columns


TableColumn<Reservation, String> travelCodeCol = new TableColumn<>("Travel Code");
travelCodeCol.setCellValueFactory(new PropertyValueFactory<>("travelCode"));

TableColumn<Reservation, String> travelFromCol = new TableColumn<>("Travel From");


travelFromCol.setCellValueFactory(new PropertyValueFactory<>("travelFrom"));

TableColumn<Reservation, String> travelToCol = new TableColumn<>("Travel To");


travelToCol.setCellValueFactory(new PropertyValueFactory<>("travelTo"));

// Ticket Information Columns


TableColumn<Reservation, String> ticketCodeCol = new TableColumn<>("Ticket Code");
ticketCodeCol.setCellValueFactory(new PropertyValueFactory<>("ticketCode"));

TableColumn<Reservation, String> ticketPriceCol = new TableColumn<>("Ticket


Price");
ticketPriceCol.setCellValueFactory(new PropertyValueFactory<>("ticketPrice"));

table.getColumns().addAll(
passengerIdCol, passportNoCol, fullNameCol,
genderCol, birthYearCol, ageCol, countryCol, nationalityCol,
passportIssueCol, passportExpiryCol, travelCodeCol, travelFromCol,
travelToCol,
ticketCodeCol, ticketPriceCol
);

table.setItems(getSampleReservations());
}

private ObservableList<Reservation> getSampleReservations() {


ObservableList<Reservation> reservations = FXCollections.observableArrayList();
reservations.add(new Reservation(
"P001", "A12345678", "Ahmed", "Ali", "Hassan",
"Al-Masri", "Male", "1990", "33", "Egypt", "Egyptian",
"2015-05-15", "2025-05-15", "TR001", "Cairo Airport",
"Dubai Airport", "TC001", "$750"
));
reservations.add(new Reservation(
"P002", "B87654321", "Sarah", "Mohammed", "Abdullah",
"Al-Saudi", "Female", "1985", "38", "Saudi Arabia", "Saudi",
"2016-03-20", "2026-03-20", "TR002", "Jeddah Airport",
"Cairo Airport", "TC002", "$650"
));
return reservations;
}

// ‫دالة مساعدة إلنشاء المربعات المعلوماتية‬

// ‫دالة مساعدة إلنشاء المربعات المعلوماتية‬


private void showAddReservationDialog() {
Alert info = new Alert(Alert.AlertType.INFORMATION);
info.setTitle("Add New Reservation");
info.setHeaderText("This would open a form to add new reservation");
info.setContentText("You can implement this dialog as needed");
info.showAndWait();
}

public static class Reservation {


private final String passengerId;
private final String passportNumber;
private final String passengerName;
private final String fatherName;
private final String grandName;
private final String surname;
private final String gender;
private final String birthYear;
private final String age;
private final String country;
private final String nationality;
private final String passportIssueDate;
private final String passportExpiryDate;
private final String travelCode;
private final String travelFrom;
private final String travelTo;
private final String ticketCode;
private final String ticketPrice;

public Reservation(String passengerId, String passportNumber, String passengerName,


String fatherName, String grandName, String surname,
String gender, String birthYear, String age,
String country, String nationality,
String passportIssueDate, String passportExpiryDate,
String travelCode, String travelFrom, String travelTo,
String ticketCode, String ticketPrice) {
this.passengerId = passengerId;
this.passportNumber = passportNumber;
this.passengerName = passengerName;
this.fatherName = fatherName;
this.grandName = grandName;
this.surname = surname;
this.gender = gender;
this.birthYear = birthYear;
this.age = age;
this.country = country;
this.nationality = nationality;
this.passportIssueDate = passportIssueDate;
this.passportExpiryDate = passportExpiryDate;
this.travelCode = travelCode;
this.travelFrom = travelFrom;
this.travelTo = travelTo;
this.ticketCode = ticketCode;
this.ticketPrice = ticketPrice;
}

// Getters for all properties


public String getPassengerId() { return passengerId; }
public String getPassportNumber() { return passportNumber; }
public String getPassengerName() { return passengerName; }
public String getFatherName() { return fatherName; }
public String getGrandName() { return grandName; }
public String getSurname() { return surname; }
public String getGender() { return gender; }
public String getBirthYear() { return birthYear; }
public String getAge() { return age; }
public String getCountry() { return country; }
public String getNationality() { return nationality; }
public String getPassportIssueDate() { return passportIssueDate; }
public String getPassportExpiryDate() { return passportExpiryDate; }
public String getTravelCode() { return travelCode; }
public String getTravelFrom() { return travelFrom; }
public String getTravelTo() { return travelTo; }
public String getTicketCode() { return ticketCode; }
public String getTicketPrice() { return ticketPrice; }
}
}
Class: 7

package AirportSystem;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.util.converter.IntegerStringConverter;

public class userManagement extends Application {


TableView<User> table;
ObservableList<User> data;

@Override
public void start(Stage primaryStage) {
table = new TableView<>();
table.setEditable(true);

// ‫تعيين األعمدة‬
TableColumn<User, Integer> idCol = new TableColumn<>("ID");
idCol.setCellValueFactory(new PropertyValueFactory<>("id"));
idCol.setCellFactory(TextFieldTableCell.forTableColumn(new
IntegerStringConverter()));
idCol.setOnEditCommit(e -> e.getRowValue().setId(e.getNewValue()));

TableColumn<User, String> usernameCol = new TableColumn<>("Username");


usernameCol.setCellValueFactory(new PropertyValueFactory<>("username"));
usernameCol.setCellFactory(TextFieldTableCell.forTableColumn());
usernameCol.setOnEditCommit(e -> e.getRowValue().setUsername(e.getNewValue()));

TableColumn<User, String> userCodeCol = new TableColumn<>("User Code");


userCodeCol.setCellValueFactory(new PropertyValueFactory<>("userCode"));
userCodeCol.setCellFactory(TextFieldTableCell.forTableColumn());
userCodeCol.setOnEditCommit(e -> e.getRowValue().setUserCode(e.getNewValue()));

TableColumn<User, String> genderCol = new TableColumn<>("Gender");


genderCol.setCellValueFactory(new PropertyValueFactory<>("gender"));
genderCol.setCellFactory(TextFieldTableCell.forTableColumn());
genderCol.setOnEditCommit(e -> e.getRowValue().setGender(e.getNewValue()));

TableColumn<User, String> passwordCol = new TableColumn<>("Password");


passwordCol.setCellValueFactory(new PropertyValueFactory<>("password"));
passwordCol.setCellFactory(TextFieldTableCell.forTableColumn());
passwordCol.setOnEditCommit(e -> e.getRowValue().setPassword(e.getNewValue()));
TableColumn<User, String> roleCol = new TableColumn<>("Role");
roleCol.setCellValueFactory(new PropertyValueFactory<>("role"));
roleCol.setCellFactory(TextFieldTableCell.forTableColumn());
roleCol.setOnEditCommit(e -> e.getRowValue().setRole(e.getNewValue()));

TableColumn<User, String> emailCol = new TableColumn<>("Email");


emailCol.setCellValueFactory(new PropertyValueFactory<>("email"));
emailCol.setCellFactory(TextFieldTableCell.forTableColumn());
emailCol.setOnEditCommit(e -> e.getRowValue().setEmail(e.getNewValue()));

table.getColumns().addAll(idCol, usernameCol, userCodeCol, genderCol, passwordCol,


roleCol, emailCol);

// ‫بيانات تجريبية‬
data = FXCollections.observableArrayList(
new User(1, "ahmed", "admin", "Male", "admin", "admin",
"[email protected]"));

table.setItems(data);

Button addBtn = new Button("Add User");


addBtn.setOnAction(e -> showAddUserPopup());

Button deleteBtn = new Button("Delete User");


deleteBtn.setOnAction(e -> {
User selected = table.getSelectionModel().getSelectedItem();
if (selected != null) {
data.remove(selected);
}
});

HBox buttonBox = new HBox(10, addBtn, deleteBtn);


buttonBox.setAlignment(Pos.CENTER);

// ‫في قسم األزرار الرئيسية‬


addBtn.setId("addBtn");
deleteBtn.setId("deleteBtn");

// ‫في نافذة البوب آب‬

// ... ‫وهكذا لباقي حقول النص‬

// ‫لمربع األزرار‬
buttonBox.getStyleClass().add("button-box");

VBox root = new VBox(10, table, buttonBox);


Scene scene = new Scene(root, 1800, 950);

scene.getStylesheets().add(getClass().getResource("userManagementStyle.css").toExternalForm
());
primaryStage.setScene(scene);
primaryStage.setTitle("User Management");
primaryStage.show();
}

private void showAddUserPopup() {


Stage popupStage = new Stage();
popupStage.setTitle("Add New User");

VBox inputFieldsBox = new VBox(10);


inputFieldsBox.setStyle("-fx-padding: 20;");
Label idLabel = new Label("ID");
TextField idField = new TextField();

Label usernameLabel = new Label("Username");


TextField usernameField = new TextField();

Label userCodeLabel = new Label("User Code");


TextField userCodeField = new TextField();

Label genderLabel = new Label("Gender");


TextField genderField = new TextField();

Label passwordLabel = new Label("Password");


TextField passwordField = new TextField();

Label roleLabel = new Label("Role");


TextField roleField = new TextField();

Label emailLabel = new Label("Email");


TextField emailField = new TextField();

Button confirmAddBtn = new Button("Confirm Add");

confirmAddBtn.setId("confirmAddBtn");
inputFieldsBox.getStyleClass().add("popup-window");
idLabel.getStyleClass().add("popup-label");
usernameLabel.getStyleClass().add("popup-label");
// ... ‫ وهكذا لباقي الـ‬Labels

idField.getStyleClass().add("popup-textfield");
usernameField.getStyleClass().add("popup-textfield");
confirmAddBtn.setOnAction(evt -> {
try {
User user = new User(
Integer.parseInt(idField.getText()),
usernameField.getText(),
userCodeField.getText(),
genderField.getText(),
passwordField.getText(),
roleField.getText(),
emailField.getText()
);
if (!user.getUsername().isEmpty()) {
data.add(user);
popupStage.close();
}
} catch (NumberFormatException ex) {
System.out.println("Invalid ID.");
}
});

inputFieldsBox.getChildren().addAll(
idLabel, idField,
usernameLabel, usernameField,
userCodeLabel, userCodeField,
genderLabel, genderField,
passwordLabel, passwordField,
roleLabel, roleField,
emailLabel, emailField,
confirmAddBtn
);
inputFieldsBox.setAlignment(Pos.CENTER);

Scene scene = new Scene(inputFieldsBox, 300, 600);


popupStage.setScene(scene);
popupStage.show();
}

public static class User {


private int id;
private String username;
private String userCode;
private String gender;
private String password;
private String role;
private String email;

public User(int id, String username, String userCode, String gender, String
password, String role, String email) {
this.id = id;
this.username = username;
this.userCode = userCode;
this.gender = gender;
this.password = password;
this.role = role;
this.email = email;
}

public int getId() { return id; }


public void setId(int id) { this.id = id; }

public String getUsername() { return username; }


public void setUsername(String username) { this.username = username; }

public String getUserCode() { return userCode; }


public void setUserCode(String userCode) { this.userCode = userCode; }

public String getGender() { return gender; }


public void setGender(String gender) { this.gender = gender; }

public String getPassword() { return password; }


public void setPassword(String password) { this.password = password; }

public String getRole() { return role; }


public void setRole(String role) { this.role = role; }

public String getEmail() { return email; }


public void setEmail(String email) { this.email = email; }
}

public static void main(String[] args) {


launch(args);
}
}
Class 8:

package AirportSystem;

public class Passenger {


String id;
String passportNumber;
String fullName;
String Nationality;
String birthyear;
String travelFrom;
String travelTo;
String ticketCode;
double ticketPrice;
public Passenger(String id,String passportNumber,String fullName,String
Nationality,String birthyear
,String travelFrom,String travelTo,String ticketCode, double ticketPrice) {
this.id = id;
this.passportNumber = passportNumber;
this.fullName = fullName;
this.Nationality = Nationality;
this.birthyear = birthyear;
this.travelFrom = travelFrom;

this.travelTo = travelTo;
this.ticketCode = ticketCode;
this.ticketPrice = ticketPrice;

}
}
Class 9:

package AirportSystem;

import java.util.HashMap;
import java.util.Map;

public class AuthenticationService {


public static Map<String,String> users = new HashMap<>();
public static boolean registerUser(String username,String password,String
confirmPassword) {
if (users.containsKey(username)) {
System.out.println("user is exist");
return false;
}
if (! password.equals(confirmPassword)) {
System.out.println("password not match");
return false;
}
users.put(username,password);
System.out.println("account has been created successfuly");
return true;
}
public static boolean loginUser(String username,String password) {
return users.containsKey(username) && users.get(username).equals(password);
}
}
Class 10:

package AirportSystem;

import javafx.application.Application;
import javafx.stage.Stage;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class DatabaseHandler {


private static List<Passenger> passengers = Collections.synchronizedList(new
ArrayList<>());

public static void addPassenger(Passenger p) {


passengers.add(p);
}
public static List<Passenger> getAllPassengers() {
return passengers;
}
}

You might also like