This Java program defines a Flight class with methods to book tickets, return tickets, and check for valid ticket IDs. The Flight class tracks the number of seats and valid ticket IDs. The main method creates a flight with 5 seats and 5 ticket IDs, books 3 tickets, tries returning an invalid ticket which throws an error, then books the remaining 2 tickets to test the seat counting.
This Java program defines a Flight class with methods to book tickets, return tickets, and check for valid ticket IDs. The Flight class tracks the number of seats and valid ticket IDs. The main method creates a flight with 5 seats and 5 ticket IDs, books 3 tickets, tries returning an invalid ticket which throws an error, then books the remaining 2 tickets to test the seat counting.
This Java program defines a Flight class with methods to book tickets, return tickets, and check for valid ticket IDs. The Flight class tracks the number of seats and valid ticket IDs. The main method creates a flight with 5 seats and 5 ticket IDs, books 3 tickets, tries returning an invalid ticket which throws an error, then books the remaining 2 tickets to test the seat counting.