DEV Community

Mike Kameta
Mike Kameta

Posted on • Edited on

100 Days of Code: The Complete Python Pro Bootcamp for 2022 - Day 16 (Object Oriented Programming)

  • I imported the code as provided by the course and all I needed to do was complete this project using OOP instead of Procedural Programming. This was a carry on or next step for the original Coffee Machine Maker for Day 15
from menu import Menu, MenuItem
from coffe_maker import CoffeeMaker
from money_machine import MoneyMachine

menu = Menu()
menu_item = MenuItem('name', 'water', 'milk', 'coffee', 'cost')
coffee_maker = CoffeeMaker()
money_machine = MoneyMachine()
is_on = True

while is_on:
    options = menu.get_items()
    choice = input(f"What would you like? ({options}): ")
    if choice == "off":
        is_on = False
    elif choice == "report":
        coffee_maker.report()
        money_machine.report()
    else:
        drink = menu.find_drink(choice)
        if coffee_maker.is_resource_sufficient(drink) and money_machine.make_payment(drink.cost):
            coffee_maker.make_coffee(drink)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)