How do we implement the seat booking process?
Let us see how we can implement the seat booking process. The Main Classes to be used for the users are:
- User
- Movie
- Theater
- Booking
- Address
- Facilities
// Java skeleton code to design an online movie
// booking system.
Enums :
public enum SeatStatus {
SEAT_BOOKED,
SEAT_NOT_BOOKED;
}
public enum MovieStatus {
Movie_Available,
Movie_NotAvailable;
}
public enum MovieType {
ENGLISH,
HINDI;
}
public enum SeatType {
NORMAL,
EXECUTIVE,
PREMIUM,
VIP;
}
public enum PaymentStatus {
PAID,
UNPAID;
}
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 Booking {
int bookingId;
int userId;
int movieId;
List<Movie> bookedSeats;
int amount;
PaymentStatus status_of_payment;
Date booked_date;
Time movie_timing;
}
class Address {
String city;
String pinCode;
String state;
String streetNo;
String landmark;
}
This is the pseudo implementation of the above logic. The above code has classes and attributes only. As you can see enums are self-explanatory.
Below is the explanation of the classes used in the above code:
- We have a Movie class which keeps all the details of the movies.
- We have users class in which users details are kept.
- Theater class in which name of the theater, it’s address and list of movies currently running are kept.
- Booking class lets you book the seat in a particular theater. It keeps a reference in Movie, Payment class.
- We have Address class which the details of the user(city, pin code, State) are kept.
Design a movie ticket booking system like Bookmyshow
We need to design an online Movie ticket booking system where a user can search for a movie in a given city and book it. This article will explain to you the architecture and implementation of the booking system.
Table of Content
- Requirements of a movie ticket booking system
- How do we implement the seat booking process?
- How to handle those cases where more than one person tries to access the same seat simultaneously?