0% found this document useful (0 votes)
21 views3 pages

Bakery Management Code

Uploaded by

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

Bakery Management Code

Uploaded by

beastgaming2037
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

class BakeryItem:

def __init__(self, name, price, quantity):

self.name = name

self.price = price

self.quantity = quantity

def update_quantity(self, quantity):

self.quantity += quantity

def get_info(self):

return f"{self.name}: ${self.price}, Quantity: {self.quantity}"

class Bakery:

def __init__(self):

self.items = {}

def add_item(self, name, price, quantity):

if name in self.items:

self.items[name].update_quantity(quantity)

else:

self.items[name] = BakeryItem(name, price, quantity)

print(f"{quantity} units of {name} added successfully.")

def display_items(self):

print("\nBakery Inventory:")

for item in self.items.values():x

print(item.get_info())

def check_availability(self, name, quantity):

if name in self.items and self.items[name].quantity >= quantity:

return True
return False

def sell_item(self, name, quantity):

if self.check_availability(name, quantity):

self.items[name].quantity -= quantity

print(f"Sold {quantity} units of {name}.")

return self.items[name].price * quantity

else:

print(f"Sorry, {name} is either out of stock or insufficient quantity available.")

return 0

def generate_bill(self, order):

total = 0

print("\nBill Details:")

for item, quantity in order.items():

if self.check_availability(item, quantity):

cost = self.sell_item(item, quantity)

print(f"{item} x {quantity} = ${cost}")

total += cost

print(f"\nTotal Amount: ${total}")

def main():

bakery = Bakery()

while True:

print("\nWelcome to the Bakery Management System")

print("1. Add Bakery Items")

print("2. Display Available Items")

print("3. Take Order")

print("4. Exit")
choice = input("Enter your choice (1-4): ")

if choice == '1':

name = input("Enter item name: ")

price = float(input("Enter price of item: "))

quantity = int(input("Enter quantity of item: "))

bakery.add_item(name, price, quantity)

elif choice == '2':

bakery.display_items()

elif choice == '3':

order = {}

while True:

item_name = input("Enter item name to order (or 'done' to finish): ")

if item_name.lower() == 'done':

break

quantity = int(input(f"Enter quantity of {item_name}: "))

order[item_name] = quantity

bakery.generate_bill(order)

elif choice == '4':

print("Thank you for using the Bakery Management System. Goodbye!")

break

else:

print("Invalid choice. Please try again.")

if __name__ == "__main__":

main()

You might also like