Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!usr/local/bin/python3.8
- # -*- coding: utf-8 -*import
- class PizzaDelivery:
- def __init__(self, name: str, price: float, ingredients: dict):
- self.ordered = False
- self.name = name
- self.price = price
- self.ingredients = ingredients
- def add_extra(self, ingredient: str, quantity: int, ingredient_price: float):
- if not self.ordered:
- if ingredient not in self.ingredients:
- self.ingredients[ingredient] = 0
- self.ingredients[ingredient] += quantity
- self.price += ingredient_price * quantity
- else:
- return f"Pizza {self.name} already prepared and we can't make any changes!"
- def remove_ingredient(self, ingredient: str, quantity: int, ingredient_price: float):
- if not self.ordered:
- if ingredient not in self.ingredients:
- return f'Wrong ingredient selected! We do not use {ingredient} in {self.name}!'
- if quantity > self.ingredients[ingredient]:
- return f'Please check again the desired quantity of {ingredient}!'
- self.ingredients[ingredient] -= quantity
- self.price -= ingredient_price * quantity
- else:
- return f"Pizza {self.name} already prepared and we can't make any changes!"
- def pizza_ordered(self):
- self.ordered = True
- return f"You've ordered pizza {self.name} prepared with" \
- f" {', '.join([f'{k}: {v}' for k, v in self.ingredients.items()])} and the price will be {self.price}lv"
Add Comment
Please, Sign In to add comment