class Event:
def __init__(self, name, date, price, available_tickets):
self.name = name
self.date = date
self.price = price
self.available_tickets = available_tickets
class TicketPurchase:
def __init__(self, event, quantity):
self.event = event
self.quantity = quantity
self.total_price = event.price * quantity
def purchase(self):
if self.quantity <= self.event.available_tickets:
self.event.available_tickets -= self.quantity
return f"Successfully purchased {self.quantity} tickets for {self.event.name}. Total cost: ${self.total_price:.2f}"
else:
return f"Insufficient tickets available for {self.event.name}. Only {self.event.available_tickets} tickets left."
# Sample events
event1 = Event("Concert", "2023-09-15", 25.0, 100)
event2 = Event("Movie Night", "2023-09-20", 10.0, 50)
# User input
event_choice = int(input("Select an event:\n1. Concert\n2. Movie Night\n"))
quantity = int(input("Enter the number of tickets you want to purchase: "))
selected_event = event1 if event_choice == 1 else event2
purchase = TicketPurchase(selected_event, quantity)
purchase_result = purchase.purchase()
print(purchase_result)