Design the booking core of a movie ticket app. Theaters have screens with seats, each screen runs shows of a movie, and users pick seats, pay and get a booking. Two users must never end up with the same seat for the same show.
Model the theater, its screens and seats, and what a show is.
The problem names theaters, screens, seats, movies and shows, but we have no classes for them. A `Theater` owns `Screen`s and a `Screen` owns its `Seat`s. A `Show` links one `Movie` to one `Screen` at a start time. A show is its own object because the same screen runs many shows a day. Keeping `Show` separate from `Screen` and `Movie` avoids copying data. We keep the physical layout simple: seats are a flat list per screen. A 2D grid or a price map can be added without changing the idea.
Track availability per show, not per seat.
Seat A1 is free for the 6 pm show and sold for the 9 pm show. Putting 'booked' on `Seat` would be wrong for one of them. A `ShowSeat` ties one `Seat` to one `Show` and carries its `SeatStatus`. A `Booking` groups the show seats a user bought. The status belongs to the pair (show, seat), so it gets its own object. This one modelling choice is what makes the whole problem solvable. More objects: a show with 200 seats has 200 `ShowSeat`s. That is cheap, and it matches how a database table would look.
Lock seats temporarily, all or nothing.
Nothing stops two users picking the same seat at the same moment, and nothing frees a seat if the user walks away. `SeatLockManager` locks a set of show seats for a user with an **expiry time**. It checks that every seat is free and locks them in one step, so it is all or nothing. `BookingService` is the entry point the UI calls. Locking all seats inside one guarded step removes the gap between 'check' and 'take' where races happen. Expired locks count as free, so abandoned carts clean themselves up. A single lock around the whole manager is simplest and correct. Locking per show, or per seat in a fixed order, lets many shows proceed in parallel at the cost of more care.
Support several payment methods without touching booking logic.
Payment is hand-waved. Cards, UPI and wallets all work differently and more will come. A `PaymentStrategy` interface with one method. `CardPayment` and `UpiPayment` implement it. `BookingService` pays through the interface, then confirms or releases the seats. The booking flow does not care how money moves, so adding a wallet is one new class (**Strategy**). A failed `pay()` simply releases the locked seats. Payment can take longer than the lock lasts. Either extend the lock when payment starts, or confirm only if the lock is still held when payment finishes.