CSE Roadmap

Core tier · about 4 hours · 6 parts

Part 3 of 6 · 1 min read

Classes

Where the truth about seats lives.

Class Job in one sentence
Seat (record) A row letter and a number
Show (record) Id, movie, screen and start time
SeatMap The only owner of seat state for one show: free, held or confirmed
Hold, Booking (records) The result of a hold and of a confirmation
PriceRule (interface) Gives the price of one seat for one show (strategy)
FlatPrice, PremiumRows A base price, and a decorator that adds a charge for back rows
Cinema Holds the shows, the holds and the bookings, and runs the flow
Clock Injected time, so a test can jump forward 11 minutes

The central rule of the design: only SeatMap decides whether a seat is free. Every other class asks it. Because it is one object per show, one lock per show is enough, and two different shows never wait for each other.

The price rule uses the decorator pattern of Level 4, module 5. PremiumRows wraps another rule and adds an extra charge for seats from a given row onward. A weekend surcharge or a discount day would be one more wrapper.

Check yourself: 1. Which class decides if a seat is free? 2. Why does each show have its own seat map? 3. Which pattern lets prices be combined?