Simulated Coffee Machine with OOP!
Add GIF demo
This commit is contained in:
parent
2cb3f14710
commit
f462cc5ae0
9 changed files with 167 additions and 2 deletions
28
Day 16/oop-coffee-machine/main.py
Normal file
28
Day 16/oop-coffee-machine/main.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from menu import Menu, MenuItem
|
||||
from coffee_maker import CoffeeMaker
|
||||
from money_machine import MoneyMachine
|
||||
|
||||
# Instantiating objects from imported classes
|
||||
my_coffee_menu = Menu()
|
||||
my_coffee_maker = CoffeeMaker()
|
||||
my_money_machine = MoneyMachine()
|
||||
|
||||
# Begin coffee machine with OOP!
|
||||
response = ""
|
||||
while response != "off":
|
||||
menu_items = my_coffee_menu.get_items()
|
||||
response = input(f"What would you like? ({menu_items}): ")
|
||||
if response == "off":
|
||||
break
|
||||
elif response == "report":
|
||||
my_coffee_maker.report()
|
||||
my_money_machine.report()
|
||||
else:
|
||||
drink = my_coffee_menu.find_drink(response)
|
||||
drink_cost = drink.cost
|
||||
if not my_coffee_maker.is_resource_sufficient(drink):
|
||||
print(f"Sorry there is not enough ingredients for {response}.")
|
||||
continue
|
||||
if not my_money_machine.make_payment(drink_cost):
|
||||
continue
|
||||
my_coffee_maker.make_coffee(drink)
|
||||
Loading…
Add table
Add a link
Reference in a new issue