Object-Oriented Design for a Movie Ticket Booking System
Problem
Design an object-oriented system for an online movie ticket booking platform where users search movies by city, view theaters and showtimes, select seats, and complete payment while handling seat concurrency and status tracking.
Solution
1. Requirements Analysis
Functional Requirements:
- Search movies playing in a specified city.
- View theaters, showtimes, and movie details.
- Select seats (normal/executive/premium/VIP) and initiate booking.
- Prevent double-booking: seats must be locked during selection/payment.
- Process payment and mark booking as paid/unpaid.
- Track booking details (user, movie, show time, seats, amount, payment status, booking timestamp).
- Maintain movie availability status (available / not available).
- Rate theaters (stored rating attribute).
Non-Functional Requirements (minimal):
- Concurrency control for seat selection (e.g., synchronized locking mechanism).
- Reliability: seat state must accurately reflect availability.
- Extensibility: easy addition of new seat types or payment statuses.
2. Use Case Diagram
Actors: User, System (for seat locking/payment processing).
Use Case Summary: A User first searches for movies playing in a chosen city. After selecting a movie, the User views theaters and showtimes, then enters interactive seat selection. The System helps by presenting current seat availability and temporarily locking chosen seats to prevent race conditions. Once seats are selected, the User confirms a booking and initiates payment. The System processes the transaction—on success it finalizes the booking and issues confirmation; on failure it releases seat locks. At any time the User can retrieve booking status (paid/unpaid and seat allocation).
Use Cases: Search Movie, View Theater Details, Select Seats, Book Tickets, Make Payment, View Booking Status.
graph TD subgraph BookingSystem UC_Search(Search Movie by City) UC_View(View Theater & Showtimes) UC_Select(Select Seats) UC_Book(Book Tickets) UC_Pay(Make Payment) UC_Status(View Booking Status) end User --> UC_Search User --> UC_View User --> UC_Select User --> UC_Book User --> UC_Pay User --> UC_Status System --> UC_Select System --> UC_Pay

3. Class Diagram
Detailed Class Explanations:
- User: Represents the customer performing searches and bookings. Stores personal profile data (name, contact info, birth date, gender) used for confirmations and potential age-based restrictions in future extensions.
- Movie: Captures a film available for booking including a link to the theater where it is showing (simplified direct association), its language/type and current availability status. In a fuller design movies would map to multiple theaters via showtimes; here we retain provided single theaterId.
- Theater: Aggregates movies currently running at a physical location. Holds identification, address, and a rating used for display ordering. The list of movies enables quick in-memory iteration for search results filtered by city.
- Address: Value object bundling location attributes for a theater (city, state, pinCode, street, landmark) to avoid scattering raw strings.
- Booking: Encapsulates a ticket purchase: references user and movie, the seats chosen (represented as a list placeholder—real design would use seat identifiers), monetary amount, payment status, booking timestamp and show timing. Transition of
status_of_paymentdrives confirmation logic. - Facilities: Placeholder for extensible amenities (parking, food court, accessibility) that could influence theater filtering; retained without attributes per source.
- Enumerations (SeatStatus, MovieStatus, MovieType, SeatType, PaymentStatus): Define constrained domains for various stateful or categorical fields ensuring validity (e.g., a seat can't be in an arbitrary string state).
- SeatBook (Conceptual Seat Manager): Provides operations for checking availability, determining seat position, handling multi-seat selections, and committing final booking which triggers payment. Represents the concurrency boundary where locks would be applied.
- Transaction: Abstracts payment processing; invoked by SeatBook during final booking to charge user and update booking state upon success or failure.
These classes together support the core user journey: discovery (User/Movie/Theater), selection (SeatBook with enumerations), and purchase (Booking/Transaction) while keeping each responsibility narrow and clear.
classDiagram class User { +int userId +String name +Date dateOfBirth +String mobNo +String emailId +String sex } class Movie { +int movieId +int theaterId +MovieType movieType +MovieStatus movieStatus } class Theater { +int theaterId +String theaterName +Address address +List<Movie> movies +float rating } class Address { +String city +String pinCode +String state +String streetNo +String landmark } class Booking { +int bookingId +int userId +int movieId +List<Movie> bookedSeats +int amount +PaymentStatus status_of_payment +Date booked_date +Time movie_timing } class Facilities { } class SeatBook { +bool seats[] +String place +String ticketType +check_availability() +position_of_seat() +multiple_tickets() +final_booking() } class Transaction { +pay(type,seats,place) } enum SeatStatus { SEAT_BOOKED; SEAT_NOT_BOOKED } enum MovieStatus { Movie_Available; Movie_NotAvailable } enum MovieType { ENGLISH; HINDI } enum SeatType { NORMAL; EXECUTIVE; PREMIUM; VIP } enum PaymentStatus { PAID; UNPAID } Theater "1" -- "*" Movie : shows User "1" -- "*" Booking : makes Booking "1" -- "1" Movie : for Booking "1" -- "1" User : by Theater "1" -- "1" Address : located_at
4. Activity Diagrams
Activity: Seat Selection & Booking
graph TD S1[User selects movie & show] --> S2[Display seat layout] S2 --> S3[User picks seats] S3 --> S4{All seats available?} S4 -- No --> S5[Notify & refresh layout] S4 -- Yes --> S6[Lock seats] S6 --> S7[Create pending Booking] S7 --> S8[Proceed to Payment]
Activity: Payment & Confirmation
graph TD P1[Initiate payment] --> P2[Process transaction] P2 --> P3{Payment success?} P3 -- Yes --> P4[Mark booking PAID] P3 -- No --> P5[Release locked seats] P4 --> P6[Email/SMS confirmation] P5 --> P7[Notify failure]
5. High-Level Code Implementation
Java
enum SeatStatus { SEAT_BOOKED, SEAT_NOT_BOOKED }
enum MovieStatus { Movie_Available, Movie_NotAvailable }
enum MovieType { ENGLISH, HINDI }
enum SeatType { NORMAL, EXECUTIVE, PREMIUM, VIP }
enum PaymentStatus { PAID, UNPAID }
class User { int userId; String name; java.util.Date dateOfBirth; String mobNo; String emailId; String sex; }
class Movie { int movieId; int theaterId; MovieType movieType; MovieStatus movieStatus; }
class Address { String city; String pinCode; String state; String streetNo; String landmark; }
class Theater { int theaterId; String theaterName; Address address; java.util.List<Movie> movies; float rating; }
class Booking { int bookingId; int userId; int movieId; java.util.List<Movie> bookedSeats; int amount; PaymentStatus status_of_payment; java.util.Date booked_date; java.sql.Time movie_timing; }
class Facilities { /* placeholder */ }
class Transaction { void pay(String ticketType, java.util.List<Integer> seatsBooked, String place) {} }
class SeatBook { Transaction transactionObj; boolean[] seats; String place; String ticketType; boolean check_availability(){return true;} int position_of_seat(){return 0;} void multiple_tickets(){} void final_booking(){ transactionObj.pay(ticketType, java.util.Collections.emptyList(), place); } }
Python
from enum import Enum
from datetime import date, time
from typing import List, Optional
class SeatStatus(Enum):
SEAT_BOOKED = 1
SEAT_NOT_BOOKED = 2
class MovieStatus(Enum):
Movie_Available = 1
Movie_NotAvailable = 2
class MovieType(Enum):
ENGLISH = 1
HINDI = 2
class SeatType(Enum):
NORMAL = 1
EXECUTIVE = 2
PREMIUM = 3
VIP = 4
class PaymentStatus(Enum):
PAID = 1
UNPAID = 2
class User:
def __init__(self, user_id: int, name: str, date_of_birth: date, mob_no: str, email_id: str, sex: str) -> None:
self.user_id = user_id
self.name = name
self.date_of_birth = date_of_birth
self.mob_no = mob_no
self.email_id = email_id
self.sex = sex
class Movie:
def __init__(self, movie_id: int, theater_id: int, movie_type: MovieType, movie_status: MovieStatus) -> None:
self.movie_id = movie_id
self.theater_id = theater_id
self.movie_type = movie_type
self.movie_status = movie_status
class Address:
def __init__(self, city: str, pin_code: str, state: str, street_no: str, landmark: str) -> None:
self.city = city
self.pin_code = pin_code
self.state = state
self.street_no = street_no
self.landmark = landmark
class Theater:
def __init__(self, theater_id: int, theater_name: str, address: Address, rating: float = 0.0) -> None:
self.theater_id = theater_id
self.theater_name = theater_name
self.address = address
self.movies: List[Movie] = []
self.rating = rating
class Booking:
def __init__(self, booking_id: int, user_id: int, movie_id: int, amount: int, status_of_payment: PaymentStatus, booked_date, movie_timing: time) -> None:
self.booking_id = booking_id
self.user_id = user_id
self.movie_id = movie_id
self.booked_seats: List[int] = []
self.amount = amount
self.status_of_payment = status_of_payment
self.booked_date = booked_date
self.movie_timing = movie_timing
class Facilities:
pass
class Transaction:
def pay(self, ticket_type: str, seats_booked: List[int], place: str) -> None:
pass
class SeatBook:
def __init__(self) -> None:
self.transaction_obj = Transaction()
self.seats: List[bool] = []
self.place: str = ""
self.ticket_type: str = ""
def check_availability(self) -> bool: return True
def position_of_seat(self) -> int: return 0
def multiple_tickets(self) -> None: pass
def final_booking(self) -> None:
self.transaction_obj.pay(self.ticket_type, [], self.place)
