Courses / Machine Coding and Low-Level Design in TypeScript / Chapter 14
Module 6 · Design problems III: meetings, cinemas and car rental · Chapter 14 of 28
Movie Ticket Booking: Shows, Seat Holds and No Double Booking
Builds on Solving a Design Problem: Requirements to Tested Code in Six Steps, Design Patterns in TypeScript: Creational, Structural and Behavioural and Parking Lot: Floors, Spots, Tickets and Fees. Next up: Car Rental: Fleet, Reservations, Pricing and Returns.
Part 1 · Requirements
What the booking system must do
A cinema sells each seat of each show once, to whoever pays first, while many people pick seats at the same moment. This chapter builds the booking side of a Kochi multiplex: seat maps, holds that expire, payment and the guard that stops one seat being sold twice.
As in the parking lot chapter, the functional requirements come first. For a multiplex with several screens, they are these.
- A screen has a fixed seat map: rows of seats, each seat in a category such as standard, premium or recliner.
- A show is one film on one screen at one start time. Each show has its own price for each category.
- A customer browses the shows, picks seats on a show and holds them. A hold keeps the seats for a short time while the customer pays.
- Paying inside the hold turns it into a booking. A hold that is not paid, or is released, gives the seats back.
- Nobody else can hold or book a seat that is held or booked, and a seat is never sold twice.