techlinks.in
Low Level Design (LLD) Coding

Low Level Design (LLD) Coding

Design (LLD) a Movie Ticket Booking System - Machine Coding

Design (LLD) a Movie Ticket Booking System - Machine Coding

techlinks.in's photo
techlinks.in
·Jun 4, 2022·

4 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

istockphoto-1177049680-612x612.jpeg

Movie Ticket Booking System

An online movie ticket booking system facilitates the purchasing of movie tickets to its customers. E-ticketing systems allow customers to browse through movies currently playing and book seats, anywhere and anytime.

Features

Our ticket booking service should meet the following requirements:

  • It should be able to list the cities where affiliate cinemas are located.
  • Each cinema can have multiple halls and each hall can run one movie show at a time.
  • Each Movie will have multiple shows.
  • Customers should be able to search movies by their title, language, genre, release date, and city name.
  • Once the customer selects a movie, the service should display the cinemas running that movie and its available shows.
  • The customer should be able to select a show at a particular cinema and book their tickets.
  • The service should show the customer the seating arrangement of the cinema hall.
  • The customer should be able to select multiple seats according to their preference.
  • The customer should be able to distinguish between available seats and booked ones.
  • The system should send notifications whenever there is a new movie, as well as when a booking is made or canceled.
  • Customers of our system should be able to pay with credit cards or cash.
  • The system should ensure that no two customers can reserve the same seat.
  • Customers should be able to add a discount coupon to their payment.

Rough Solution (LLD-Machine Coding)

Basic Entity

  • Admin: Responsible for adding new movies and their shows, canceling any movie or show, blocking/unblocking customers, etc.
  • FrontDeskOfficer: Can book/cancel tickets.
  • Customer: Can view movie schedules, book, and cancel tickets.
  • Guest: All guests can search movies but to book seats they have to become a registered member.
  • System: Mainly responsible for sending notifications for new movies, bookings, cancellations, etc.

Final Code

public enum BookingStatus {
  REQUESTED, PENDING, CONFIRMED, CHECKED_IN, CANCELED, ABANDONED
}

public enum SeatType {
  REGULAR, PREMIUM, ACCESSIBLE, SHIPPED, EMERGENCY_EXIT, OTHER
}

public enum AccountStatus {
  ACTIVE, BLOCKED, BANNED, COMPROMISED, ARCHIVED, UNKNOWN
}

public enum PaymentStatus {
  UNPAID, PENDING, COMPLETED, FILLED, DECLINED, CANCELLED, ABANDONED, SETTLING, SETTLED, REFUNDED
}

public class Address {
  private String streetAddress;
  private String city;
  private String state;
  private String zipCode;
  private String country;
}
// For simplicity, we are not defining getter and setter functions. The reader can
// assume that all class attributes are private and accessed through their respective
// public getter method and modified only through their public setter method.

public class Account {
  private String id;
  private String password;
  private AccountStatus status;

  public boolean resetPassword();
}

public abstract class Person {
  private String name;
  private Address address;
  private String email;
  private String phone;

  private Account account;
}

public class Customer extends Person {
  public boolean makeBooking(Booking booking);
  public List<Booking> getBookings();
}

public class Admin extends Person {
  public boolean addMovie(Movie movie);
  public boolean addShow(Show show);
  public boolean blockUser(Customer customer);
}

public class FrontDeskOfficer extends Person {
  public boolean createBooking(Booking booking);
}

public class Guest {
  public bool registerAccount();
}
public class Show {
  private int showId;
  private Date createdOn;
  private Date startTime;
  private Date endTime;
  private CinemaHall playedAt;
  private Movie movie;
}

public class Movie {
  private String title;
  private String description;
  private int durationInMins;
  private String language;
  private Date releaseDate;
  private String country;
  private String genre;
  private Admin movieAddedBy;

  private List<Show> shows;
  public List<Show> getShows();
}
public class Booking {
  private String bookingNumber;
  private int numberOfSeats;
  private Date createdOn;
  private BookingStatus status;

  private Show show;
  private List<ShowSeat> seats;
  private Payment payment;

  public boolean makePayment(Payment payment);
  public boolean cancel();
  public boolean assignSeats(List<ShowSeat> seats);
}

public class ShowSeat extends CinemaHallSeat{
  private int showSeatId;
  private boolean isReserved;
  private double price;
}

public class Payment {
  private double amount;
  private Date createdOn;
  private int transactionId;
  private PaymentStatus status;
}
public class City {
  private String name;
  private String state;
  private String zipCode;
}

public class Cinema {
  private String name;
  private int totalCinemaHalls;
  private Address location;

  private List<CinemaHall> halls;
}

public class CinemaHall {
  private String name;
  private int totalSeats;

  private List<CinemaHallSeat> seats;
  private List<Show> shows;
}
public interface Search {
  public List<Movie> searchByTitle(String title);
  public List<Movie> searchByLanguage(String language);
  public List<Movie> searchByGenre(String genre);
  public List<Movie> searchByReleaseDate(Date relDate);
  public List<Movie> searchByCity(String cityName);
}

public class Catalog implements Search {
   HashMap<String, List<Movie>> movieTitles;
   HashMap<String, List<Movie>> movieLanguages;
   HashMap<String, List<Movie>> movieGenres;
   HashMap<Date, List<Movie>> movieReleaseDates;
   HashMap<String, List<Movie>> movieCities;

  public List<Movie> searchByTitle(String title) {
    return movieTitles.get(title);
  }

  public List<Movie> searchByLanguage(String language) {
    return movieLanguages.get(language);
  }

  //...

  public List<Movie> searchByCity(String cityName) {
    return movieCities.get(cityName);
  }
}

Did you find this article valuable?

Support techlinks.in by becoming a sponsor. Any amount is appreciated!

See recent sponsors Learn more about Hashnode Sponsors
 
Share this