main.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from menu import Menu, MenuItem
  2. from coffee_maker import CoffeeMaker
  3. from money_machine import MoneyMachine
  4. from time import sleep
  5. menu = Menu()
  6. coffee_maker = CoffeeMaker()
  7. money_machine = MoneyMachine()
  8. is_on = True
  9. while is_on:
  10. available_drinks = menu.get_items(coffee_maker.resources)
  11. if available_drinks is None:
  12. sleep(3)
  13. print("Sorry. The machine not have needful ingredients. Back again later")
  14. sleep(5)
  15. break
  16. else:
  17. while True:
  18. choice = input(f"What would you like? Available: ({available_drinks}): ").lower()
  19. if choice == "off":
  20. is_on = False
  21. print()
  22. break
  23. elif choice == "report":
  24. coffee_maker.report()
  25. money_machine.report()
  26. break
  27. else:
  28. drink = menu.find_drink(choice)
  29. if drink and coffee_maker.is_resource_sufficient(drink):
  30. is_successful_payment = money_machine.make_payment(drink.cost)
  31. if is_successful_payment:
  32. coffee_maker.make_coffee(drink)
  33. break
  34. print("Bye, bye!")