Preparing your design workspace

Loading the problem and your saved attempt…

Design a Flight Seat Booking System

Model per-flight seat maps, all-or-nothing party bookings, seat changes and cancellations so that no seat is ever given to two passengers.

For this exercise, assume one airline's seat booking system that runs in memory for flights that are already scheduled. Every flight uses an aircraft layout that lists its seats: each seat has a row-and-letter label such as 14C and belongs to one cabin class, economy or business. Many flights can use the same layout.

A customer or an airline agent can: - see which seats on a flight are still free, optionally for one cabin class; - book a party of one or more passengers on one flight, choosing one seat for each passenger; a successful booking gets a booking reference; - change one passenger's seat to another free seat in the same cabin class on the same flight; - cancel a booking, which frees all of its seats.

These rules must always hold: a seat on a flight belongs to at most one passenger in an active booking; every passenger in an active booking has exactly one seat; booking a party is all or nothing, so if any chosen seat is unknown or already taken, no seat is booked; and a seat change keeps the passenger's old seat until the new seat is secured.

Report these outcomes explicitly: unknown flight, unknown seat, seat already taken, the same seat chosen twice in one request, an empty party, a seat change into another cabin class, and a booking that does not exist or is already cancelled.

Payments and fares, check-in, waitlists, overbooking, temporary seat holds, connecting flights and persistence are outside scope.

Design the objects and their responsibilities, the public contracts, and how the objects work together. Do not write code.