def run_machine(): menu = Menu() coffee_maker = CoffeeMaker() money_machine = MoneyMachine() while True: # TODO: Prompt user by asking “What would you like? (espresso/latte/cappuccino):” order = input(f"What would you like? ({menu.get_items()}): ") # TODO: Turn off the Coffee Machine by entering “off” to the prompt. if order == 'off': break # TODO: Print report elif order == 'report': coffee_maker.report() money_machine.report() else: validated_order = menu.find_drink(order) # TODO: Check resources sufficient is_enough_ingredients = coffee_maker.is_resource_sufficient( validated_order) # TODO: Process Coins is_payment_successful = money_machine.make_payment( validated_order.cost) # TODO: Check transaction successful if is_enough_ingredients and is_payment_successful: coffee_maker.make_coffee(validated_order)
def check_resources(user_order): global new_menu money_machine = MoneyMachine() coffee_maker = CoffeeMaker() if user_order == 'report': new_report = CoffeeMaker() return new_report.report() elif user_order == 'off': is_on = False return is_on else: new_drink = new_menu.find_drink(user_order) coffee_machine = CoffeeMaker() if coffee_machine.is_resource_sufficient( new_drink) and money_machine.make_payment(new_drink.cost): coffee_maker.make_coffee(user_order)
def start(menu=Menu(), coffee_maker=CoffeeMaker(), money_machine=MoneyMachine()): # TODO 1: Prompt user asking what would you like? answer_list = ["espresso", "latte", "cappuccino", "off", "report"] answer = input(f"What would you like? ({menu.get_items()}): ").lower() while answer not in answer_list: print("Wrong answer. Please type again.") answer = input(f"What would you like? ({menu.get_items()}): ").lower() # TODO 2: Turn off the coffee machine by entering off to the prompt if answer == "off": print("Turning off the coffee machine. Good bye.") return # TODO 3: Print Report elif answer == "report": coffee_maker.report() money_machine.report() # TODO 4: Check resources suficient elif menu.find_drink(answer) is not None: item = menu.find_drink(answer) if coffee_maker.is_resource_sufficient(item): # TODO 5: Process coins payment_successfully = money_machine.make_payment(item.cost) # TODO 6: Check transaction successfull? if payment_successfully: # TODO 7: Make coffee coffee_maker.make_coffee(item) # Restart start(menu, coffee_maker, money_machine)
def main(): # This is the menu menu = Menu() cm = CoffeeMaker() mm = MoneyMachine() while True: drinks = menu.get_items() choice = input(f"What drink would you like? We serve {drinks} ") if choice == "off": print("Coffee machine turning off...") return elif choice == "report": cm.report() mm.report() continue else: # Check user selected a valid drink drink = menu.find_drink(choice) if drink == 'e': # error catcher continue if cm.is_resource_sufficient(drink): if mm.make_payment(drink.cost): cm.make_coffee(drink) else: continue else: continue
def coffee_machine(): my_coffee_machine = CoffeeMaker() my_money_machine = MoneyMachine() my_menu = Menu() machine_off = False while not machine_off: options = my_menu.get_items() choice = input(f"Which drink would you like ({options}) ? \n > ") if choice == 'report': my_coffee_machine.report() my_money_machine.report() elif choice == 'off': machine_off = True else: selected_drink = my_menu.find_drink(choice) if selected_drink is not None: # Check if sufficient resources is_resource_sufficient = my_coffee_machine.is_resource_sufficient( selected_drink) if is_resource_sufficient: # Take payment is_paid_amount_sufficient = False while not is_paid_amount_sufficient: is_paid_amount_sufficient = my_money_machine.make_payment( selected_drink.cost) # Once enough money provided, and transaction registered, make coffee my_coffee_machine.make_coffee(selected_drink)
def main(): menu = Menu() coffee_maker = CoffeeMaker() money_machine = MoneyMachine() is_cm_running = True while is_cm_running: # ask for user Input is_input_invalid = True while is_input_invalid: user_action = input("What would you like? (espresso/latte/cappuccino): ").lower() if user_action == "espresso" or \ user_action == "latte" or \ user_action == "cappuccino" or \ user_action == "report" or \ user_action == "off": is_input_invalid = False else: print("Invalid input!") if user_action == "off": is_cm_running = False continue elif user_action == "report": coffee_maker.report() money_machine.report() else: coffee = menu.find_drink(user_action) if coffee_maker.is_resource_sufficient(coffee) and \ money_machine.make_payment(coffee.cost): coffee_maker.make_coffee(coffee)
def main(): is_on = True menu = Menu() coffee_maker = CoffeeMaker() money_machine = MoneyMachine() while is_on: choice = input(f"What would you like? ({menu.get_items()}): ") if choice == "report": coffee_maker.report() money_machine.report() elif choice == "off": is_on = False else: # search for the drink drink = menu.find_drink(choice) # make sure its exists if drink: # make sure we have the resources if coffee_maker.is_resource_sufficient(drink): # and that we got enough money if money_machine.make_payment(drink.cost): # do it! coffee_maker.make_coffee(drink)
def run_coffee_machine(): menu = Menu() # menu_item = MenuItem() coffee_maker = CoffeeMaker() money_machine = MoneyMachine() def input_response(): """Returns the user response for the choice of drink""" resp = input(f"What would you like? {menu.get_items()}: ") if resp not in ['espresso', 'latte', 'cappuccino', 'report', 'off']: resp = input(f"What would you like? {menu.get_items()}: ") return resp def handle_drink(a_drink): """Gets the money made from each transaction and updates the resources """ if coffee_maker.is_resource_sufficient( a_drink) and money_machine.make_payment(a_drink.cost): coffee_maker.make_coffee(a_drink) # start of the routine response = input_response() while response: if response == 'off': return elif response == 'report': coffee_maker.report() response = input_response() else: drink = menu.find_drink(response) handle_drink(drink) response = input_response()
def user_interaction(): # creating the coffee maker, the menu and the money machine my_coffee_maker = CoffeeMaker() my_menu = Menu() my_money_machine = MoneyMachine() currently_attending = True while currently_attending: chosen_coffee_type = input(f"What would you like? ({my_menu.get_items()}) ").lower() if chosen_coffee_type == "report": # creating the report my_coffee_maker.report() my_money_machine.report() elif chosen_coffee_type == "off": currently_attending = False else: my_menu_item = my_menu.find_drink(chosen_coffee_type) if my_coffee_maker.is_resource_sufficient(my_menu_item): # proceeding to coin processing as sufficient resources if my_money_machine.make_payment(my_menu_item.cost): # coffee can be made now my_coffee_maker.make_coffee(my_menu_item)
def coffee_machine(): """Starts the coffee machine and makes it run""" # Creates a new CoffeeMaker object coffee_maker = CoffeeMaker() # Creates a new MoneyMachine object money_machine = MoneyMachine() # Creates a new Menu object menu = Menu() # Initializes the variable indicating if the machine goes off off = False # As long as the machine is not off, it runs while not off: # Displays the machine's menu to the user and stores his choice user_choice = input( f"What would you like? ({menu.get_items()}): ").lower() # Checks the user's choice if user_choice == "off": # The user is a technician and turned off the machine using the choice "off" # The variable off becomes True which will stop the machine off = True elif user_choice == "report": # The user asked for a report of the machine's resources using the choice "report" # Prints the coffee maker report coffee_maker.report() # Prints the money machine report money_machine.report() else: # Looks for the user's choice in the menu drink = menu.find_drink(user_choice) # Checks if the user selected an existing drink if drink != "None": # The user asked for a drink among the menu # Checks if the machine has sufficient resources to make the drink if coffee_maker.is_resource_sufficient(drink): # The machine has sufficient resources # Asks the user to insert coins and checks if the user inserted enough to pay the drink money_machine.make_payment(drink.cost) # Deducts ingredients of the drink from the machine's resources coffee_maker.make_coffee(drink) else: # The user made an invalid choice # Prints the user he made an invalid choice print("Invalid choice")
def drink_machine(): cm = CoffeeMaker() mm = MoneyMachine() m = Menu() while True: drink = request(cm, mm, m) if cm.is_resource_sufficient(drink): if mm.make_payment(drink.cost): cm.make_coffee(drink)
def coffee_machine(): should_run_machine = True while should_run_machine: myMenu = Menu() choice = input(f"What would you like to have? {myMenu.get_items()}: ") myMenuItem = myMenu.find_drink(order_name=choice) if myMenuItem == None: should_run_machine = False else: maker = CoffeeMaker() if maker.is_resource_sufficient: myMoneyMachine = MoneyMachine() if myMoneyMachine.make_payment(myMenuItem.cost): maker.make_coffee(myMenuItem) print(maker.report())
def play(): again = True menu = Menu() coffe = CoffeeMaker() money = MoneyMachine() while again: order_name = input(f"What would you like? {menu.get_items()}: ") if order_name == "off": again = False elif order_name == "report": coffe.report() money.report() else: order = menu.find_drink(order_name) if coffe.is_resource_sufficient(order): if money.make_payment(order.cost): coffe.make_coffee(order)
def coffee_machine(): menu = Menu() coffee_maker = CoffeeMaker() money_machine = MoneyMachine() while True: options = menu.get_items() choice = input(f'What would you like? ({options}): ').lower() if choice == 'off': return elif choice == 'report': coffee_maker.report() money_machine.report() else: coffee = menu.find_drink(choice) if coffee_maker.is_resource_sufficient(coffee): if money_machine.make_payment(coffee.cost): coffee_maker.make_coffee(coffee)
def order_coffee(): menu = Menu() coffee_maker = CoffeeMaker() money_machine = MoneyMachine() is_on = True while is_on: user_input = input(f"What would you like? {menu.get_items()}:") if user_input == 'off': is_on = False elif user_input == 'report': coffee_maker.report() money_machine.report() else: drink = menu.find_drink(user_input) if drink and coffee_maker.is_resource_sufficient( drink) and money_machine.make_payment(drink.cost): coffee_maker.make_coffee(drink)
def main(): cm = CoffeeMaker() mm = MoneyMachine() menu = Menu() is_on = True while is_on: print() choice = input("What would you like? (%s): " % menu.get_items()) if choice == 'report': cm.report() mm.report() elif choice == 'off': is_on = False else: drink = menu.find_drink(choice) if drink and cm.is_resource_sufficient(drink): if mm.make_payment(drink.cost): cm.make_coffee(drink)
def coffee_machine(): my_menu = Menu() my_coffee_maker = CoffeeMaker() my_money_machine = MoneyMachine() machine_on = True while machine_on: order = input(f'What would you like? ({my_menu.get_items()}) ') if order == 'off': print('Shutting down. Good bye.') machine_on = False elif order == 'report': my_coffee_maker.report() my_money_machine.report() else: drink = my_menu.find_drink(order) if drink is not None and \ my_coffee_maker.is_resource_sufficient(drink) and \ my_money_machine.make_payment(drink.cost): my_coffee_maker.make_coffee(drink)
def coffee_machine(): print('Welcome to coffee machine ☕') coffee_maker = CoffeeMaker() money_machine = MoneyMachine() menu = Menu() options = menu.get_items() user_input = input(f'What would you like? ({options}): ') if user_input == 'report': coffee_maker.report() money_machine.report() return coffee_machine() elif user_input == 'off': print('Bye than') return else: drink = menu.find_drink(user_input) if coffee_maker.is_resource_sufficient(drink) and money_machine.make_payment(drink.cost): coffee_maker.make_coffee(drink) another_coffee = input('Would you like to have another coffee? "yes" or "no": ') if another_coffee == 'yes': return coffee_machine()
def main(): is_on = True menu = Menu() coffee_maker = CoffeeMaker() money_machine = MoneyMachine() while is_on: selection = menu.display() ##print(coffee_maker.is_resource_sufficient('cappuccino')) if selection == 'off': print("Turning OFF the machine") is_on = False elif selection == 'report': coffee_maker.report() money_machine.report() else: options = menu.get_items(selection) if coffee_maker.is_resource_sufficient(options): money_machine.collect_coins(selection, options.cost) coffee_maker.make_coffee(options)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine my_money_machine = MoneyMachine() my_coffee_machine = CoffeeMaker() my_menu = Menu() machine_on = True while machine_on: options = my_menu.get_items() customer_order = input(f"What would you like? ({options}) ") if customer_order == "off": print("Turning off.") machine_on = False elif customer_order == "report": my_coffee_machine.report() my_money_machine.report() else: drink = my_menu.find_drink(customer_order) if my_coffee_machine.is_resource_sufficient( drink) and my_money_machine.make_payment(drink.cost): my_coffee_machine.make_coffee(drink)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine coffee_maker = CoffeeMaker() money_machine = MoneyMachine() menu = Menu() 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)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine menu=Menu() maker=CoffeeMaker() money=MoneyMachine() def coffeemachineMK2(): while True: choice=input(f"What do you want? {menu.get_items()} :").lower() if choice=="report": print(maker.report()) print(money.report()) continue elif choice=="off": print(f"The machine is off\n{money.report()}") return 0 drink=menu.find_drink(choice) if maker.is_resource_sufficient(drink) and money.make_payment(drink.cost): maker.make_coffee(drink) coffeemachineMK2()
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine my_menu = Menu() my_coffer_maker = CoffeeMaker() my_money_machine = MoneyMachine() while True: word = input("What would you like? (espresso/latte/cappuccino): ") if word == "off": break elif word == "report": my_coffer_maker.report() my_money_machine.report() else: drink = my_menu.find_drink(word) if drink == None: print("Invalid Word") else: if my_coffer_maker.is_resource_sufficient( drink) and my_money_machine.make_payment(drink.cost): my_coffer_maker.make_coffee(drink)
from menu import Menu from coffee_maker import CoffeeMaker from money_machine import MoneyMachine CoffeMakerObj = CoffeeMaker() MoneyMachineObj = MoneyMachine() MenuObj = Menu() while True: cmd = input(f"What would you like? ({MenuObj.get_items()}) [or 'report']: ").lower() if cmd == 'off': print("Goodbye!") break if cmd == 'report': CoffeMakerObj.report() MoneyMachineObj.report() else: drink = MenuObj.find_drink(cmd) if not drink: continue if not CoffeMakerObj.is_resource_sufficient(drink): continue if not MoneyMachineObj.make_payment(drink.cost): continue CoffeMakerObj.make_coffee(drink)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine from replit import clear machine = CoffeeMaker() wallet = MoneyMachine() menu = Menu() machine_on = True while machine_on: clear() option = input( 'What do you want to do?\n(1) - Buy a coffee\n(2) - Print Report\n(3) - Turn off machine\n You option is: ' ) if option == '1': clear() coffee_option = input( 'What coffee do you want?\n(1) - Espresso\n(2) - Latte\n(3) - Cappuccino\n You option is: ' ) if coffee_option == '1': coffee = 'espresso' elif coffee_option == '2': coffee = 'latte' elif coffee_option == '3': coffee = 'cappuccino' if machine.is_resource_sufficient(menu.find_drink(coffee)): if wallet.make_payment(menu.find_drink(coffee).cost): machine.make_coffee(menu.find_drink(coffee)) else:
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine usrReq = "" cm = CoffeeMaker() cm_menu = Menu() mm = MoneyMachine() while usrReq != "No": usrReq = input(f"What would you like? ({cm_menu.get_items()}): ").lower() if usrReq == "no": break elif usrReq == "report": cm.report() else: drink = cm_menu.find_drink(usrReq) if drink != None: if cm.is_resource_sufficient(drink): if mm.make_payment(drink.cost): cm.make_coffee(drink)
""" Day 016 of the 100 Days of Code course Author: Wayne Kwiat Date: 1/16/2021 """ from menu import Menu from coffee_maker import CoffeeMaker from money_machine import MoneyMachine money_transaction = MoneyMachine() drink_dispenser = CoffeeMaker() menu = Menu() 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": drink_dispenser.report() money_transaction.report() else: drink = menu.find_drink(choice) ingredient_check = drink_dispenser.is_resource_sufficient(drink) payment = money_transaction.make_payment(drink.cost) if ingredient_check and payment: drink_dispenser.make_coffee(drink)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine storage = CoffeeMaker() menu_item = Menu() money = MoneyMachine() menu_items = menu_item.get_items() while 1 > 0: question = input(f"What would you like? ({menu_items}) : ").lower() if question == "report": storage.report() money.report() elif question == "off": break elif question in menu_items: if storage.is_resource_sufficient(menu_item.find_drink(question)): product = menu_item.find_drink(question) product_cost = product.cost if money.make_payment(product_cost): storage.make_coffee(menu_item.find_drink(question)) else: print("Invalid entry please choose from the 3 choices")
from coffee_maker import CoffeeMaker from menu import Menu from money_machine import MoneyMachine money_machine, coffee_maker, menu = MoneyMachine(), CoffeeMaker(), Menu() choice = input(f"What would you like? ({menu.get_items()}): ") while choice != 'off': if choice == "report": coffee_maker.report() money_machine.report() elif choice == "espresso" or choice == "latte" or choice == "cappuccino": drink = menu.find_drink(choice) if coffee_maker.is_resource_sufficient( drink) and money_machine.make_payment(drink.cost): coffee_maker.make_coffee(drink) else: print("Invalid choice. Try Again") choice = input("What would you like? (espresso/latte/cappuccino): ")
#timmy.left(90) #my_screen = Screen() #print(my_screen.canvheight) #my_screen.exitonclick() #table = PrettyTable() #new_city = "CasaBlanca" # #table.add_column("Type", [f"{new_city}", "Water", "Fire"]) #table.add_column("Website", ["Pikachu", "Squirty", "Charmander"]) # #table.align = "l" #print(table) # COFFEE MAKER OBJECT from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine my_menu = Menu() print(my_menu.get_items()) print(my_menu.find_drink("latte")) print(my_menu.find_drink("cappuccino")) #menu_items = MenuItem() #print(menu_items) make_coffee = CoffeeMaker() print(make_coffee.report()) print(make_coffee.make_coffee("Latte"))