Commit a3b95bf5 authored by Raquel's avatar Raquel 💬

Update restaurant_costumers.py

parent fd871f3d
class Dish:
def __init__(self,name, price, ingredients):
self.name=name
......@@ -15,70 +14,46 @@ class Dish:
profit= self.price - self.cost()
return profit
def __str__(self):
return self.name
class Restaurant:
def __init__(self):
self.order=[]
def order_dish(self,client,dish):
self.order.append([client,dish])
return self.order
def print_orders(self, client):
for order in self.order:
return f" Customer {client} \n Order # {self.order.index(order)} : {order[1]} - {order[1].price}"
def print_check(self,client):
total=0
# this code is just to assure the customer name will be printed only once
if len(list(zip(*self.order))[0]) > 0: #zip retrieves the first element accross a lists and returns a list with them
print(f" Customer {client} \n ")
#end
for order in self.order:
if order[0] == client:
total += order[1].price
print( f" Order # {self.order.index(order)} : {order[1]} - {order[1].price}")
print(f" Total: {total}")
class Ingredients:
def __init__(self,name, cost):
self.name=name
self.cost=cost
cheese = Ingredients('Cheese', 5)
pepperoni = Ingredients('pepperoni', 5)
dough = Ingredients('dough', 5)
pizza = Dish("Pizza", 35, [cheese, pepperoni, dough])
salad = Dish("salad", 35, [cheese, pepperoni, dough])
restaurant= Restaurant()
restaurant.order_dish("Goofy", pizza)
restaurant.order_dish("Goofy", salad)
#print(restaurant.print_orders("Goofy"))
restaurant.print_check("Goofy")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment