From the course: C# Hands-on Practice with Data-Structures
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
GitHub Codespace Solution: Flight reservation system - C# Tutorial
From the course: C# Hands-on Practice with Data-Structures
GitHub Codespace Solution: Flight reservation system
Let's finish implementing the Flight and FlightReservationSystem classes. First, we'll decide what data structures to use for our passengers and waitlist. For our passengers, we could use a List, but there's no required order for our passengers. It's just a group of passengers. So instead, we'll use a HashSet. A HashSet stores unique elements, in this case, passengers, and automatically handles duplicates. It's useful for ensuring that each passenger is added only once, and it has efficient operations for checking whether an item is present, adding new items, and removing items. For our waitlist, we'll use a queue. A queue follows the first-in-first-out principle, which is exactly what we need for managing waitlists. The first person added to the waitlist should be the first one offered a seat if it becomes available. Let's initialize these with our constructor. Then we'll implement the methods. For BookSeat, we'll check if there are available seats by subtracting the number of…