Preparing your design workspace

Loading the problem and your saved attempt…

Design a Travel Website with Flights, Hotel Ratings, and Top Activities

Model flight seat booking, hotel and activity ratings, and a top-activities list for a travel website, then design the objects, contracts, and extensions around them.

For this exercise, assume a travel website covers a fixed set of cities, and the site's staff load its catalog of flights, hotels, and activities (loading is not part of the exercise).

A flight has an ID, an origin city, a destination city, a departure date and time, and a number of seats; there is one seat class, so every seat is the same, and every flight in the catalog is still open for booking. A hotel and an activity each have an ID, a name, and one city.

A traveler, identified by a traveler ID (sign-in is out of scope), can: (1) search flights by origin city, destination city, and date; only flights with at least one free seat are shown, ordered by departure time and then by flight ID, and all matches are returned at once; (2) book 1 to 4 seats on one flight in a single request, all or nothing, which creates a booking with an ID the site assigns, and cancel a booking by its ID as a whole, which gives its seats back; cancelling a booking that is already cancelled says so and changes nothing; (3) rate a hotel or an activity from 1 to 5 stars; a traveler has at most one rating per hotel or activity, and rating the same one again replaces the earlier rating; (4) list a city's hotels, ordered by name, each with its average rating and number of ratings, or "not rated" when it has none; (5) see a city's top activities: the 3 activities of that city with the highest average rating, ties broken by more ratings and then by name, with unrated activities left out (fewer than 3 are listed when fewer are rated).

An unknown city, flight, hotel, activity, or booking, a seat count outside 1 to 4, a request for more seats than are free, and a star value outside 1 to 5 each return a clear result. Design the objects, their responsibilities, the interfaces, and the interactions. No code is needed.

Follow-ups add other things travelers can rate and other ranking rules, and have many travelers book and rate at the same time. Payments and prices, hotel room booking, several seat classes, seat maps, accounts, and storage and scaling are out of scope.