0% found this document useful (0 votes)
11 views6 pages

Premium Cinema Booking System Guide

Uploaded by

rejicow818
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

Premium Cinema Booking System Guide

Uploaded by

rejicow818
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import mysql.

connector
from datetime import datetime
import sys

class PremiumCinemaSystem:
def __init__(self):
[Link] = self.connect_db()
self.current_screening = None

def connect_db(self):
try:
return [Link](
host="localhost",
user="root", # Make sure to replace with your MySQL username
password="1221", # Make sure to replace with your MySQL password
database="movie_booking",
autocommit=True
)
except [Link] as err:
print(f"Database connection error: {err}")
[Link](1)

def display_halls_movies(self):
cursor = [Link](dictionary=True)

query = """
SELECT
h.hall_id, h.hall_name,
h.has_dolby, h.has_3d,
s.screening_id,
[Link], [Link], [Link], m.is_3d,
s.start_time, s.end_time,
COUNT(b.booking_id) AS booked_seats,
[Link] - COUNT(b.booking_id) AS available_seats
FROM Halls h
JOIN Screenings s ON h.hall_id = s.hall_id
JOIN Movies m ON s.movie_id = m.movie_id
LEFT JOIN Bookings b ON s.screening_id = b.screening_id
WHERE s.start_time > NOW()
GROUP BY h.hall_id, s.screening_id
ORDER BY h.hall_id, s.start_time
"""

[Link](query)
screenings = [Link]()
[Link]()

if not screenings:
print("No screenings available currently.")
[Link](1)

current_date = screenings[0]['start_time'].strftime('%A, %B %d, %Y')


halls = {}

for s in screenings:
hall_id = s['hall_id']
if hall_id not in halls:
specs = []
if s['has_dolby']: [Link]("Dolby")
if s['has_3d']: [Link]("3D")
halls[hall_id] = {
'name': s['hall_name'],
'specs': ", ".join(specs),
'screenings': []
}

screening_time = s['start_time'].strftime('%I:%M %p')


movie_3d = " (3D)" if s['is_3d'] else ""
hall_3d = "3D " if s['is_3d'] and s['has_3d'] else ""

halls[hall_id]['screenings'].append({
'id': s['screening_id'],
'movie': f"{hall_3d}{s['title']}{movie_3d}",
'rating': s['rating'],
'time': screening_time,
'duration': f"{s['duration']} min",
'available': s['available_seats']
})

print(f"\n🎬 PREMIUM CINEMA - SCREENINGS FOR {current_date} 🎬")

for hall_id, hall_data in [Link]():


print(f"\n⭐ {hall_data['name']} ({hall_data['specs']}) ⭐")

# Manually format table headers and rows


headers = ["ID", "Movie", "Rating", "Time", "Duration", "Available"]
col_widths = [max(len(header), 10) for header in headers] # Minimum
width of 10

# Calculate the maximum width for each column based on the content
for s in hall_data['screenings']:
col_widths[0] = max(col_widths[0], len(f"[{s['id']}]"))
col_widths[1] = max(col_widths[1], len(s['movie']))
col_widths[2] = max(col_widths[2], len(f"⭐ {s['rating']}"))
col_widths[3] = max(col_widths[3], len(s['time']))
col_widths[4] = max(col_widths[4], len(s['duration']))
col_widths[5] = max(col_widths[5], len(f"{s['available']} seats"))

# Print header row


header_line = (
f"{headers[0]:<{col_widths[0]}} "
f"{headers[1]:<{col_widths[1]}} "
f"{headers[2]:<{col_widths[2]}} "
f"{headers[3]:<{col_widths[3]}} "
f"{headers[4]:<{col_widths[4]}} "
f"{headers[5]:<{col_widths[5]}}"
)
print(header_line)
print("-" * len(header_line)) # Separator line

# Print data rows


for s in hall_data['screenings']:
print(
f"[{s['id']}]".ljust(col_widths[0]) + " " +
s['movie'].ljust(col_widths[1]) + " " +
f"⭐ {s['rating']}".ljust(col_widths[2]) + " " +
s['time'].ljust(col_widths[3]) + " " +
s['duration'].ljust(col_widths[4]) + " " +
f"{s['available']} seats".ljust(col_widths[5])
)

return screenings

def display_seat_map(self, screening_id):


cursor = [Link](dictionary=True)

[Link]("""
SELECT s.*, [Link], h.hall_name, h.has_dolby, h.has_3d
FROM Screenings s
JOIN Movies m ON s.movie_id = m.movie_id
JOIN Halls h ON s.hall_id = h.hall_id
WHERE s.screening_id = %s
""", (screening_id,))
screening = [Link]()
self.current_screening = screening

[Link]("""
SELECT st.seat_id, st.seat_number, st.seat_class, st.row_type,
[Link], st.is_recliner,
CASE WHEN b.booking_id IS NULL THEN 0 ELSE 1 END AS booked
FROM Seats st
LEFT JOIN Bookings b ON st.seat_id = b.seat_id
AND b.screening_id = %s
WHERE st.hall_id = %s
ORDER BY st.seat_number
""", (screening_id, screening['hall_id']))
seats = [Link]()
[Link]()

seat_map = {}
for seat in seats:
seat_map[seat['seat_number']] = seat

print(f"\n{'-'*80}")
print(f" {screening['title']}")
print(f" {screening['hall_name']} | 🕒
{screening['start_time'].strftime('%I:%M %p')}")
if screening['has_dolby']: print("🔊 Dolby Atmos")
if screening['has_3d']: print("👓 3D Screening")
print(f"{'-'*80}\n")

rows = ['A', 'B', 'C', 'D', 'E', 'F', 'G']


cols = range(1, 8)

print(" " + "".join([f" {col:<2} " for col in cols]))


print(" " + "".join(["-----" for _ in cols]))

for row in rows:


row_label = f"{row} |"
row_display = row_label

for col in cols:


seat_id = f"{row}{col}"
if seat_id in seat_map:
seat = seat_map[seat_id]
if seat['booked']:
row_display += " [❌] "
else:
if seat['seat_class'] == 'Diamond':
row_display += f" [💎{seat_id}]"
elif seat['seat_class'] == 'Gold':
row_display += f" [🌟{seat_id}]"
elif seat['seat_class'] == 'Silver':
row_display += f" [🔹{seat_id}]"
else:
row_display += f" [🔸{seat_id}]"
else:
row_display += " [ ] "

print(row_display)

print("\nSEAT CLASSES:")
print(f"💎 Diamond (Premium Lounge, Recliners) - $
{self.get_price_for_class('Diamond'):.2f}")
print(f"🌟 Gold (Premium Lounge) - ${self.get_price_for_class('Gold'):.2f}")
print(f"🔹 Silver (Standard) - ${self.get_price_for_class('Silver'):.2f}")
print(f"🔸 Bronze (Balcony) - ${self.get_price_for_class('Bronze'):.2f}")
print("\n❌ = Booked | [ ] = Not available\n")

return seat_map

def get_price_for_class(self, seat_class):


cursor = [Link](dictionary=True)
[Link]("""
SELECT price FROM Seats
WHERE hall_id = %s AND seat_class = %s
LIMIT 1
""", (self.current_screening['hall_id'], seat_class))
result = [Link]()
[Link]()
return result['price'] if result else 0

def book_seats(self, seat_map):


seats_to_book = []

print("\n🛒 SELECT YOUR SEATS (Enter 'done' when finished)")

while True:
seat_num = input("\nEnter seat number (e.g., A1): ").upper().strip()

if seat_num.lower() == 'done':
if not seats_to_book:
print("Please select at least one seat.")
continue
break

if seat_num not in seat_map:


print("❌ Invalid seat number. Please try again.")
continue

if seat_map[seat_num]['booked']:
print("❌ This seat is already booked. Please choose another.")
continue

seat_data = seat_map[seat_num]
name = input(f" Name for {seat_num} ({seat_data['seat_class']} class):
").strip()

if not name:
print("❌ Name cannot be empty.")
continue

seats_to_book.append({
'seat_id': seat_data['seat_id'],
'number': seat_num,
'class': seat_data['seat_class'],
'price': seat_data['price'],
'name': name
})

print(f"✅ Added {seat_num} ({seat_data['seat_class']} class)")


print(f"Current selection ({len(seats_to_book)} seats):")
for seat in seats_to_book:
print(f" {seat['number']}: {seat['name']} (${seat['price']:.2f})")

while True:
mobile = input("\n📱 Enter your mobile number: ").strip()
if mobile:
break
print("❌ Mobile number cannot be empty")

total = sum(float(s['price']) for s in seats_to_book)

print("\n🧾 BOOKING SUMMARY")


print(f"Screening: {self.current_screening['title']}")
print(f"Time: {self.current_screening['start_time'].strftime('%I:%M %p')}")
print(f"Hall: {self.current_screening['hall_name']}\n")

print("Selected Seats:")
for seat in seats_to_book:
print(f" {seat['number']}: {seat['name']} ({seat['class']}): $
{seat['price']:.2f}")

print(f"\n💵 TOTAL AMOUNT: ${total:.2f}")

confirm = input("\nConfirm booking? (Y/N): ").upper()


if confirm != 'Y':
print("❌ Booking cancelled.")
return

cursor = [Link]()
try:
booking_date = [Link]()

for seat in seats_to_book:


[Link]("""
INSERT INTO Bookings
(screening_id, seat_id, customer_name, mobile_number,
booking_date)
VALUES (%s, %s, %s, %s, %s)
""", (
self.current_screening['screening_id'],
seat['seat_id'],
seat['name'],
mobile,
booking_date
))

print("\n BOOKING CONFIRMED! 🎉")


print(f"\n📞 We've sent details to {mobile}")
print("ℹ️ Please arrive 30 minutes before showtime")
print("\nEnjoy your movie!\n")

except [Link] as err:


print(f"❌ Booking failed: {err}")
finally:
[Link]()

def run(self):
print("\n" + "="*50)
print("🌟 PREMIUM CINEMA BOOKING SYSTEM 🌟")
print("="*50)

while True:
screenings = self.display_halls_movies()

try:
screening_id = int(input("\nEnter Screening ID to book (0 to exit):
"))
if screening_id == 0:
break

if not any(s['screening_id'] == screening_id for s in screenings):


print("❌ Invalid screening ID")
continue

seat_map = self.display_seat_map(screening_id)

self.book_seats(seat_map)

again = input("Book another screening? (Y/N): ").upper()


if again != 'Y':
break

except ValueError:
print("❌ Please enter a valid number")

[Link]()
print("\nThank you for using our booking system! 👋\n")

if __name__ == "__main__":
cinema = PremiumCinemaSystem()
[Link]()

You might also like