class Admin extends User {
// Constructor for Admin class
public Admin(int userId, String username, String password) {
super(userId, username, password); // Call the parent constructor to set
user details
}
@Override
public void handleActions() {
// Admin-specific actions menu
while (true) {
System.out.println("Welcome, Admin!");
System.out.println("1. Add a new flight");
System.out.println("2. View all flights");
System.out.println("3. Log out");
System.out.print("Choose an option: ");
int choice = AerowayBookingSystem.scanner.nextInt();
AerowayBookingSystem.scanner.nextLine(); // consume newline
// Switch to perform actions based on the Admin's choice
switch (choice) {
case 1:
AerowayBookingSystem.addFlight(); // Calls the addFlight method
in AerowayBookingSystem class
break;
case 2:
AerowayBookingSystem.viewFlights(); // Calls the viewFlights
method in AerowayBookingSystem class
break;
case 3:
System.out.println("Logging out...");
return; // Exit the loop and log out
default:
System.out.println("Invalid choice.");
}
}
}
}