These are the notes for Low-Level Design (LLD) episode 74: the first half of designing a movie ticket booking app, the kind of app BookMyShow is. It is one of the most asked machine-coding questions. Part 1 covers the requirements, the places (City, Cinema, Screen, Seat, SeatType), the big idea (Movie vs Show), searching shows, a seat map per show, pricing per seat type, and the booking flow. Part 2 (episode 75) handles two users grabbing the same seat at once, holds and payments.
How the code was run: every program was saved as Main.java in a fresh folder and run with javac Main.java && java -cp . Main on OpenJDK 21. Every output below is the real output, pasted exactly. The cinemas, the film "Chai Express", shows and prices are made up. Nothing here describes how the real BookMyShow app is built; we design our own.
1. The problem: a family trip to the cinema
| At the cinema | In the design |
|---|---|
| The same film plays in many halls, at many times | Movie (what) vs Show (when and where) |
| Each hall has a seat chart bolted to the floor | Screen with a fixed list of Seats |
| A fresh chart for every show; taken seats crossed out | A seat map per Show |
| Recliners cost more than the front rows | SeatType and pricing per seat type |
| The clerk checks all your seats, adds up the bill, crosses them all out, hands you a ticket | The booking flow and a Booking |
2. Movie booking requirements: the words
- City: a place like Pune; it has cinemas.
- Cinema: one building, like "Star Cinema"; it has screens.
- Screen: one hall inside a cinema, with its own seats (also called an auditorium).
- Seat: one place to sit, with an id like
A1(row A, seat 1) and a seat type. - SeatType: the kind of seat, which decides the price:
REGULAR,PREMIUM,RECLINER. - Movie: the film itself: title, length, language.
- Show: one screening: a movie, on one screen, at one start time.
- Booking: the result of buying tickets: an id, the show, the user, the seats, the amount, a status.
Requirements we agreed:
- Search shows of a movie in a city, sorted by time.
- See the seat map of one show: free and booked seats.
- The price depends on the seat type (and can differ per show).
- Book several seats at once: all of them, or none.
3. Attempt 1: the seats live inside the Movie
class Movie { // attempt: the seats live inside the movie
final String name;
final boolean[] booked = new boolean[10]; // seats A1..A10
final int price = 200; // one price for every seat
Movie(String name) { this.name = name; }
void book(int seat, String show) {
if (booked[seat - 1]) {
System.out.println(show + ": A" + seat + " already booked!"); return; }
booked[seat - 1] = true;
System.out.println(show + ": booked A" + seat + " for " + price);
}
}
public class Main { public static void main(String[] args) {
Movie m = new Movie("Chai Express");
m.book(1, "6 PM, Screen 1"); // Asha
m.book(1, "9 PM, Screen 1"); // Ravi: a DIFFERENT show
m.book(1, "6 PM, Screen 2"); // Neha: a different hall
m.book(12, "6 PM, Screen 3"); // the big hall: 12 seats in row A
} }
Real output:
6 PM, Screen 1: booked A1 for 200
9 PM, Screen 1: A1 already booked!
6 PM, Screen 2: A1 already booked!
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 11 out of bounds for length 10
at Movie.book(Main.java:7)
at Main.main(Main.java:18)
Why it failed
- One
bookedarray for the whole film, so the 9 PM show and Screen 2 share the seats of the 6 PM show in Screen 1. - The hall size is hard-coded to 10: a 12-seat row crashes with
ArrayIndexOutOfBoundsException: Index 11 out of bounds for length 10(arrays start at index 0, so seat 12 is index 11). - One price for every seat.
The root cause: what, where and when were mixed into one class.
4. The fix: City, Cinema, Screen, Seat, Movie and Show
Three questions, three kinds of class:
- What is shown?
Movie(title, minutes, language). - Where?
Cinema(name, city, screens),Screen(name, seats),Seat(id, type): a layout that never changes. - When?
Show(id, movie, cinema, screen, start): one movie on one screen at one time. Bookings belong to the Show.
They are records: classes that only hold values (Java writes the constructor, getters like title(), equals, hashCode and toString).
import java.time.LocalTime; import java.util.*;
enum SeatType { REGULAR, PREMIUM, RECLINER }
record Seat(String id, SeatType type) {} // A1, REGULAR
record Screen(String name, List<Seat> seats) {} // the hall: its layout never changes
record Cinema(String name, String city, List<Screen> screens) {}
record Movie(String title, int minutes, String language) {} // WHAT is shown
record Show(String id, Movie movie, Cinema cinema, Screen screen, LocalTime start) {} // what+where+when
class Catalogue {
final List<Show> shows = new ArrayList<>();
List<Show> search(String city, String title) { // "Chai Express in Pune"
return shows.stream().filter(s -> s.cinema().city().equals(city) && s.movie().title().equals(title))
.sorted(Comparator.comparing(Show::start)).toList(); }
}
public class Main { public static void main(String[] args) {
List<Seat> layout = List.of(new Seat("A1", SeatType.REGULAR), new Seat("A2", SeatType.REGULAR),
new Seat("B1", SeatType.PREMIUM), new Seat("C1", SeatType.RECLINER));
Screen s1 = new Screen("Screen 1", layout), s2 = new Screen("Screen 2", layout);
Cinema star = new Cinema("Star Cinema", "Pune", List.of(s1, s2));
Cinema moon = new Cinema("Moon Talkies", "Nagpur", List.of(new Screen("Screen 1", layout)));
Movie chai = new Movie("Chai Express", 142, "Hindi");
Catalogue cat = new Catalogue();
cat.shows.add(new Show("S2", chai, star, s1, LocalTime.of(21, 0)));
cat.shows.add(new Show("S1", chai, star, s1, LocalTime.of(18, 0)));
cat.shows.add(new Show("S3", chai, star, s2, LocalTime.of(18, 0)));
cat.shows.add(new Show("S4", chai, moon, moon.screens().get(0), LocalTime.of(18, 0)));
for (Show s : cat.search("Pune", "Chai Express"))
System.out.println(s.id() + " " + s.start() + " " + s.cinema().name() + ", " + s.screen().name());
} }
Real output:
S1 18:00 Star Cinema, Screen 1
S3 18:00 Star Cinema, Screen 2
S2 21:00 Star Cinema, Screen 1
searchuses a stream:filterkeeps the shows that match the city and title,sorted(Comparator.comparing(Show::start))orders them by start time, andtoList()collects them.LocalTime.of(18, 0)is a time of day with no date: 18:00, which is 6 PM.- The Nagpur show (S4) is filtered out; S1, S3, S2 come back in time order even though they were added out of order.
5. A seat map per show, with pricing per seat type
A seat map is the picture of the hall you tap on: the hall's rows, with booked seats marked. Each Show keeps its own set of booked seat ids (a Set has no duplicates, so a seat can't be in it twice) and its own price map, Map<SeatType, Integer>, so the night show can be cheaper.
import java.util.*;
enum SeatType { REGULAR, PREMIUM, RECLINER }
record Seat(String id, SeatType type) {}
class Show { // each show has its OWN bookings and prices
final String id; final List<List<Seat>> rows; final Map<SeatType, Integer> price;
final Set<String> booked = new HashSet<>();
Show(String id, List<List<Seat>> rows, Map<SeatType, Integer> price) {
this.id = id; this.rows = rows; this.price = price; }
void printSeatMap() { // the seat map: [XX] = booked
System.out.println("Show " + id + " ---- SCREEN ----");
for (List<Seat> row : rows) {
SeatType t = row.get(0).type(); var line = new StringBuilder(String.format("%-9s", t));
for (Seat s : row) line.append(booked.contains(s.id()) ? " [XX]" : " [" + s.id() + "]");
System.out.println(line + " " + price.get(t) + " rupees");
} } }
public class Main {
static List<Seat> row(String r, int n, SeatType t) {
List<Seat> seats = new ArrayList<>();
for (int i = 1; i <= n; i++) seats.add(new Seat(r + i, t));
return seats; }
static Map<SeatType, Integer> prices(int regular, int premium, int recliner) { // price per type
return Map.of(SeatType.REGULAR, regular, SeatType.PREMIUM, premium, SeatType.RECLINER, recliner); }
public static void main(String[] args) {
var layout = List.of(row("A", 5, SeatType.REGULAR), row("B", 5, SeatType.PREMIUM),
row("C", 3, SeatType.RECLINER));
Show evening = new Show("S1", layout, prices(180, 250, 450));
Show night = new Show("S2", layout, prices(150, 220, 400));
evening.booked.addAll(List.of("A1", "B3", "C1"));
evening.printSeatMap(); night.printSeatMap(); } } // same hall, another show: nothing booked
Real output:
Show S1 ---- SCREEN ----
REGULAR [XX] [A2] [A3] [A4] [A5] 180 rupees
PREMIUM [B1] [B2] [XX] [B4] [B5] 250 rupees
RECLINER [XX] [C2] [C3] 450 rupees
Show S2 ---- SCREEN ----
REGULAR [A1] [A2] [A3] [A4] [A5] 150 rupees
PREMIUM [B1] [B2] [B3] [B4] [B5] 220 rupees
RECLINER [C1] [C2] [C3] 400 rupees
- Show S1 has A1, B3 and C1 booked (
[XX]), with each row's price. - Show S2 uses the same layout but has no bookings and lower prices: that's the "fresh chart for every show".
String.format("%-9s", t)pads the seat type to 9 characters, left-aligned, so the rows line up.Map.of(...)makes a small fixed map. For enum keys, anEnumMapis a faster alternative.
6. The booking flow: validate, price, all or nothing
If you take seats one by one, a failure halfway leaves half a booking behind (the user gets A2 but not B1, which they never wanted). So the flow has three steps:
- Validate every seat: does it exist on this screen? Is it free?
- Price: add up the price of each seat's type.
- Take them all at once, and return a Booking with status
CONFIRMED.
This "all or nothing" property is called atomicity (from "atom", something you can't split).
import java.util.*;
enum SeatType { REGULAR, PREMIUM, RECLINER } enum BookingStatus { CONFIRMED, CANCELLED }
record Seat(String id, SeatType type) {}
record Booking(String id, String show, String user, List<String> seats, int amount, BookingStatus status) {}
class Show {
final String id; final Map<SeatType, Integer> price;
final Map<String, Seat> seats = new LinkedHashMap<>(); final Set<String> booked = new HashSet<>();
Show(String id, List<Seat> layout, Map<SeatType, Integer> price) {
this.id = id; this.price = price; layout.forEach(s -> seats.put(s.id(), s)); } }
class BookingService { private int next = 1; // the booking flow, step by step
Booking book(Show show, String user, List<String> wanted) {
for (String id : wanted) { // 1. validate EVERY seat first
if (!show.seats.containsKey(id)) throw new IllegalArgumentException(id + " does not exist");
if (show.booked.contains(id)) throw new IllegalStateException(id + " is already booked"); }
int amount = 0; // 2. price per seat type
for (String id : wanted) amount += show.price.get(show.seats.get(id).type());
show.booked.addAll(wanted); // 3. only now take them all: all or nothing
return new Booking("BK" + next++, show.id, user, wanted, amount, BookingStatus.CONFIRMED); } }
public class Main { public static void main(String[] args) {
List<Seat> layout = List.of(new Seat("A1", SeatType.REGULAR), new Seat("A2", SeatType.REGULAR),
new Seat("B1", SeatType.PREMIUM), new Seat("C1", SeatType.RECLINER));
var price = Map.of(SeatType.REGULAR, 180, SeatType.PREMIUM, 250, SeatType.RECLINER, 450);
Show s1 = new Show("S1", layout, price); BookingService svc = new BookingService();
System.out.println(svc.book(s1, "Asha", List.of("A1", "B1")));
try { svc.book(s1, "Ravi", List.of("A2", "B1")); } // A2 is free, B1 is not
catch (RuntimeException e) { System.out.println("Ravi: " + e.getMessage()); }
System.out.println("A2 still free? " + !s1.booked.contains("A2"));
svc.book(s1, "Neha", List.of("Z9")); } }
Real output:
Booking[id=BK1, show=S1, user=Asha, seats=[A1, B1], amount=430, status=CONFIRMED]
Ravi: B1 is already booked
A2 still free? true
Exception in thread "main" java.lang.IllegalArgumentException: Z9 does not exist
at BookingService.book(Main.java:13)
at Main.main(Main.java:28)
- Asha's booking BK1: A1 (REGULAR, 180) + B1 (PREMIUM, 250) = 430, CONFIRMED.
- Ravi asked for A2 (free) and B1 (taken):
B1 is already booked, and A2 is still free: all or nothing worked. - Neha asked for Z9:
IllegalArgumentException: Z9 does not exist.
Two exceptions, two meanings:
IllegalArgumentException: the input is wrong (there is no seat Z9).IllegalStateException: the input is fine, but the current state says no (B1 is already booked).
7. The class diagram
City ──▶ Cinema (name, city) 1 ── * Screen (name, layout) 1 ── * Seat (id, SeatType)
Movie (title, minutes, language) SeatType: REGULAR · PREMIUM · RECLINER
Show = Movie + Cinema + Screen + start time ─▶ booked seats + price per SeatType (its own)
Catalogue.search(city, title) ─▶ shows, sorted by start time
BookingService.book(show, user, seats):
1 validate every seat (exists? free?) 2 price per seat type 3 take all ─▶ Booking (CONFIRMED)
8. Interview follow-ups
| Question | Answer |
|---|---|
| Two users tap the same seat at once? | Seat locking: next episode. |
| Paying takes time? | Hold the seats for a few minutes, then confirm after payment: next episode. |
| Cancelling? | Status CANCELLED, free the seats (see the mini project). |
| Weekend and morning prices? | A PricingStrategy (episode 34) that takes the show and seat type. |
| Search by language or date? | More filters on the same search (see the mini project). |
| Millions of shows? | Index shows by (city, movie) in a map, or query a database with an index on those columns. |
9. Common mistakes
| Mistake | What you see (real) | Fix |
|---|---|---|
| Seats inside the Movie | 9 PM, Screen 1: A1 already booked! |
Bookings per Show |
| A fixed-size seat array | java.lang.ArrayIndexOutOfBoundsException: Index 11 out of bounds for length 10 |
A Screen with a list of seats |
| One price for every seat | a recliner sold at 200 | Price per SeatType, per Show |
| Booking seat by seat | half a booking left behind | Validate all, then take all |
| No check that a seat exists | a ticket for a seat that isn't there | IllegalArgumentException: Z9 does not exist |
| The same seat twice in one request | the user pays twice for one seat | Reject duplicates: a seat is listed twice (mini project) |
Mini project: catalogue, seat map, booking and cancelling
Adds search by language and date, a seat map with the show's details, checks for an empty request and a duplicated seat, and cancellation that frees the seats.
import java.time.*;
import java.util.*;
enum SeatType { REGULAR, PREMIUM, RECLINER }
enum BookingStatus { CONFIRMED, CANCELLED }
record City(String name) {}
record Seat(String id, SeatType type) {}
record Screen(String name, List<List<Seat>> rows) {
Optional<Seat> seat(String id) {
return rows.stream().flatMap(List::stream).filter(s -> s.id().equals(id)).findFirst();
}
}
record Cinema(String name, City city, List<Screen> screens) {}
record Movie(String title, int minutes, String language) {}
class Show {
final String id; final Movie movie; final Cinema cinema; final Screen screen; final LocalDateTime start;
final Map<SeatType, Integer> price; final Set<String> booked = new HashSet<>();
Show(String id, Movie m, Cinema c, Screen s, LocalDateTime start, Map<SeatType, Integer> price) {
this.id = id; movie = m; cinema = c; screen = s; this.start = start; this.price = price;
}
void printSeatMap() {
System.out.println(id + " " + movie.title() + " " + start + " at " + cinema.name() + ", " + screen.name());
for (List<Seat> row : screen.rows()) {
StringBuilder line = new StringBuilder(String.format(" %-9s", row.get(0).type()));
for (Seat s : row) line.append(booked.contains(s.id()) ? " [XX]" : " [" + s.id() + "]");
System.out.println(line + " " + price.get(row.get(0).type()));
}
}
}
record Booking(String id, Show show, String user, List<String> seats, int amount, BookingStatus status) {
Booking cancelled() { return new Booking(id, show, user, seats, amount, BookingStatus.CANCELLED); }
}
class Catalogue {
final List<Show> shows = new ArrayList<>();
List<Show> search(String city, String title, String language, LocalDate date) {
return shows.stream()
.filter(s -> s.cinema.city().name().equals(city) && s.movie.title().equals(title))
.filter(s -> language == null || s.movie.language().equals(language))
.filter(s -> date == null || s.start.toLocalDate().equals(date))
.sorted(Comparator.comparing((Show s) -> s.start)).toList();
}
}
class BookingService {
private int next = 1;
final Map<String, Booking> bookings = new LinkedHashMap<>();
Booking book(Show show, String user, List<String> wanted) {
if (wanted.isEmpty()) throw new IllegalArgumentException("pick at least one seat");
if (new HashSet<>(wanted).size() != wanted.size()) throw new IllegalArgumentException("a seat is listed twice");
int amount = 0;
for (String id : wanted) {
Seat seat = show.screen.seat(id).orElseThrow(() -> new IllegalArgumentException(id + " does not exist"));
if (show.booked.contains(id)) throw new IllegalStateException(id + " is already booked");
amount += show.price.get(seat.type());
}
show.booked.addAll(wanted);
Booking b = new Booking("BK" + next++, show, user, List.copyOf(wanted), amount, BookingStatus.CONFIRMED);
bookings.put(b.id(), b);
return b;
}
Booking cancel(String bookingId) {
Booking b = bookings.get(bookingId);
if (b == null || b.status() == BookingStatus.CANCELLED) throw new IllegalStateException("cannot cancel " + bookingId);
b.show().booked.removeAll(b.seats());
Booking c = b.cancelled(); bookings.put(c.id(), c);
return c;
}
}
public class Main {
static List<Seat> row(String r, int n, SeatType t) {
List<Seat> seats = new ArrayList<>();
for (int i = 1; i <= n; i++) seats.add(new Seat(r + i, t));
return seats;
}
public static void main(String[] args) {
City pune = new City("Pune");
List<List<Seat>> layout = List.of(row("A", 4, SeatType.REGULAR), row("B", 4, SeatType.PREMIUM), row("C", 2, SeatType.RECLINER));
Screen s1 = new Screen("Screen 1", layout);
Cinema star = new Cinema("Star Cinema", pune, List.of(s1));
Movie hi = new Movie("Chai Express", 142, "Hindi"), mr = new Movie("Chai Express", 142, "Marathi");
Map<SeatType, Integer> evening = Map.of(SeatType.REGULAR, 180, SeatType.PREMIUM, 250, SeatType.RECLINER, 450);
Catalogue cat = new Catalogue();
Show sh1 = new Show("S1", hi, star, s1, LocalDateTime.of(2026, 11, 20, 18, 0), evening);
Show sh2 = new Show("S2", mr, star, s1, LocalDateTime.of(2026, 11, 20, 21, 0), evening);
Show sh3 = new Show("S3", hi, star, s1, LocalDateTime.of(2026, 11, 21, 18, 0), evening);
cat.shows.addAll(List.of(sh3, sh2, sh1));
for (Show s : cat.search("Pune", "Chai Express", "Hindi", null)) System.out.println("Hindi show: " + s.id + " " + s.start);
for (Show s : cat.search("Pune", "Chai Express", null, LocalDate.of(2026, 11, 20))) System.out.println("on 20 Nov: " + s.id + " " + s.movie.language());
BookingService svc = new BookingService();
Booking b1 = svc.book(sh1, "Asha", List.of("A1", "A2", "C1"));
System.out.println(b1.id() + " " + b1.user() + " " + b1.seats() + " " + b1.amount() + " " + b1.status());
sh1.printSeatMap();
for (List<String> wanted : List.of(List.of("B1", "B1"), List.of("C1", "C2"), List.of("D1"), List.<String>of())) {
try { svc.book(sh1, "Ravi", wanted); }
catch (RuntimeException e) { System.out.println("Ravi " + wanted + ": " + e.getClass().getSimpleName() + ": " + e.getMessage()); }
}
System.out.println(svc.cancel("BK1").status() + ", C1 free again: " + !sh1.booked.contains("C1"));
System.out.println(svc.book(sh1, "Ravi", List.of("C1", "C2")).amount());
try { svc.cancel("BK1"); } catch (IllegalStateException e) { System.out.println(e.getMessage()); }
}
}
Real output:
Hindi show: S1 2026-11-20T18:00
Hindi show: S3 2026-11-21T18:00
on 20 Nov: S1 Hindi
on 20 Nov: S2 Marathi
BK1 Asha [A1, A2, C1] 810 CONFIRMED
S1 Chai Express 2026-11-20T18:00 at Star Cinema, Screen 1
REGULAR [XX] [XX] [A3] [A4] 180
PREMIUM [B1] [B2] [B3] [B4] 250
RECLINER [XX] [C2] 450
Ravi [B1, B1]: IllegalArgumentException: a seat is listed twice
Ravi [C1, C2]: IllegalStateException: C1 is already booked
Ravi [D1]: IllegalArgumentException: D1 does not exist
Ravi []: IllegalArgumentException: pick at least one seat
CANCELLED, C1 free again: true
900
cannot cancel BK1
What happened:
- The Hindi filter found S1 and S3; the date filter (20 November) found S1 (Hindi) and S2 (Marathi).
- Asha booked A1, A2 (180 each) and C1 (450): 810.
- Ravi's four bad requests each failed with a clear message, and nothing was taken.
- Cancelling BK1 freed C1, so Ravi could then book C1 and C2: 450 + 450 = 900.
- Cancelling BK1 a second time is refused.
Practice
1. Add a convenience fee of 30 rupees per ticket.
Answer
In step 2 of the flow: amount += show.price.get(type) + FEE with static final int FEE = 30;. Better: keep the ticket price and the fee as separate fields of Booking so the receipt can show both.
2. Print the seat map with one booking's seats marked differently ([ME]).
Answer
Pass the booking's seat list to printSeatMap(Set<String> mine): for each seat, print [ME] if mine.contains(id), [XX] if booked by others, otherwise [id].
3. Why is the price map on the Show and not on the Screen?
Answer
The same hall can charge different prices at different times (a morning show is cheaper than a weekend evening). The layout belongs to the Screen; the prices belong to the Show.
4. A Screen gets a new row of seats next month. What happens to old shows?
Answer
Old shows should keep the layout they were sold with. Either give each Show its own copy of the layout when it's created, or version the layout (Screen → Layout v1, Layout v2) and store the version on the Show.
5. Write the search as a loop instead of a stream.
Answer
List<Show> result = new ArrayList<>();
for (Show s : shows)
if (s.cinema().city().equals(city) && s.movie().title().equals(title)) result.add(s);
result.sort(Comparator.comparing(Show::start));
return result;
Quick quiz
In show S1, prices are REGULAR 180, PREMIUM 250, RECLINER 450, and B1 is already booked. Ravi calls book(S1, "Ravi", [A2, C1, B1]). What does he get? (a) A2 and C1, 630 rupees (b) A2, C1 and B1, 880 rupees (c) nothing: "B1 is already booked" (d) A2 only, 180 rupees
Answer
(c). Step 1 validates every seat before taking any. B1 is booked, so IllegalStateException: B1 is already booked is thrown, and A2 and C1 stay free.
Interview questions
- Why separate Movie and Show? A movie is shown many times in many halls; bookings and prices belong to one screening.
- What does a Show contain? Movie, cinema, screen, start time, its booked seats and its prices.
- Why does the Screen own the seats? The layout is physical and fixed; every show in that hall uses it.
- How do you price seats? A map from seat type to price, per show (or a pricing strategy).
- How do you make a multi-seat booking atomic? Validate all seats first, then take all of them in one step (and in a real system, in one transaction or under a lock).
- How do you search shows fast? Index by (city, movie title), then filter by date and language and sort by time.
- What is in a Booking? Id, show, user, seats, amount, status, created time.
- What happens on cancel? Status CANCELLED, seats freed, refund by policy (episode 75).
- Which class decides if a seat exists? The show's screen layout.
- Which exception when? IllegalArgumentException for bad input, IllegalStateException for a valid request the current state forbids.
Glossary
| Term | Meaning, with an example |
|---|---|
| Movie booking requirements | What the app must do: search shows, show the seat map, price seats, book several at once |
| City | A place that has cinemas: Pune |
| Cinema | One building with screens: Star Cinema |
| Screen | One hall in a cinema with its own seats: Screen 1 |
| Seat | One place to sit, with an id and a type: Seat("A1", REGULAR) |
| SeatType | The kind of seat that decides the price: REGULAR, PREMIUM, RECLINER |
| Movie | The film: Movie("Chai Express", 142, "Hindi") |
| Show | One screening: a movie on a screen at a start time |
| Booking | The purchase: id, show, user, seats, amount, status |
| BookingStatus | CONFIRMED or CANCELLED |
| Search shows | Find a movie's shows in a city, sorted by time |
| Seat map | The hall's rows with booked seats marked: [XX] |
| Pricing per seat type | A map SeatType → rupees, per show |
| Booking flow | Validate every seat, price, take all, return a Booking |
| All or nothing (atomic) | Either every seat is booked or none is |
| Record | A class that only holds values; Java writes the boilerplate |
| Enum | A fixed list of named values |
| LocalTime / LocalDateTime | A time of day / a date with a time: LocalTime.of(18, 0) |
| Stream | A pipeline over a collection: filter, sort, collect |
| Comparator.comparing | Builds a sort order from a key: by start time |
| Set | A collection with no duplicates: the booked seat ids |
| Map.of / EnumMap | A small fixed map / a fast map with enum keys |
| LinkedHashMap | A map that remembers insertion order |
| ArrayIndexOutOfBoundsException | Using an array index outside 0..length-1 |
| IllegalArgumentException | Thrown when the input itself is wrong: Z9 does not exist |
| IllegalStateException | Thrown when the current state forbids it: B1 is already booked |
| Optional | A box that may or may not hold a value: screen.seat("D1") |
Summary
- Seats inside the Movie made every show share them, crashed on a bigger hall, and had one price.
- City → Cinema → Screen → Seat describe where; Movie is what; a Show is a movie on a screen at a time, and owns its bookings and prices.
- Search filters shows by city and title and sorts by time; each show prints its own seat map.
- The booking flow validates every seat, prices them by seat type, and takes all or nothing.
- Next episode: BookMyShow part 2: seat locking, holds, payments and concurrency.