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 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 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)
class CoffeeMachine: def __init__(self): self.money_machine = MoneyMachine() self.coffee_maker = CoffeeMaker() self.menu = Menu() def run(self): is_on = True while is_on: options = self.menu.get_items() choice = input(f"What would you like? ({options}): ").lower() if choice == "off": is_on = False elif choice == "report": self.coffee_maker.report() self.money_machine.report() else: drink = self.menu.find_drink(choice) if drink != "None": is_enough_ingredients = self.coffee_maker.is_resource_sufficient( drink) is_payment_successful = False if is_enough_ingredients: is_payment_successful = self.money_machine.make_payment( drink.cost) if is_payment_successful: self.coffee_maker.make_coffee(drink)
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 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 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)
class CoffeeMachine: def __init__(self): self.on = True self.menu = Menu() self.coffee_maker = CoffeeMaker() self.money_machine = MoneyMachine() def start(self): while self.on: print("Welcome to your coffee machine!\n") request = input( f"\nWhat would you like? ({self.menu.get_items()}):").lower() if request == "off": self.on = False print("Bye bye!") elif request == "report": self.coffee_maker.report() self.money_machine.report() else: order = self.menu.find_drink(request) if order: sufficient_resources = self.coffee_maker.is_resource_sufficient( order) if sufficient_resources: cost = order.cost print( f"\nIt will be {self.money_machine.CURRENCY}{cost}" ) if self.money_machine.make_payment(cost): self.coffee_maker.make_coffee(order)
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 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)
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 my_menu = Menu() coffee_alpha = CoffeeMaker() register_one = MoneyMachine() machine_status = True while machine_status: selection = input("What would you like to drink?: ") if selection == "report": coffee_alpha.report() register_one.report() elif selection == "off": machine_status = False else: drink = my_menu.find_drink(selection) if drink != "None": if coffee_alpha.is_resource_sufficient(drink): register_one.make_payment(drink.cost) coffee_alpha.make_coffee(drink)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine coffee_machine = CoffeeMaker() money = MoneyMachine() menu = Menu() off = False while not off: options = Menu.get_items() order = input(f"What would you like to order? ({items}): ") if order == "report": coffee_maker.report() money.report() elif order == "off": off = True print("Turning coffee machine off.") else drink = menu.find_drink(order) enough_resources = coffee_machine.is_resource_sufficient(drink) enough_money = money.make_payment(drink.cost) if enough_resources and enough_money: coffee_machine.make_coffee(drink)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine check_out = MoneyMachine() coffee_maker = CoffeeMaker() order_menu = Menu() is_on = True while is_on: user_choice = input(f"What would you like to have? {order_menu.get_items()} ").lower() if user_choice == "report": coffee_maker.report() check_out.report() elif user_choice == "off": is_on = False else: user_choice = order_menu.find_drink(user_choice) if coffee_maker.is_resource_sufficient(user_choice): check_out.make_payment(user_choice.cost) coffee_maker.make_coffee(user_choice)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine menu = Menu() items = Menu.get_items(Menu()) CoffeeMaker = CoffeeMaker() MoneyMachine = MoneyMachine() order = "on" while not order == "off": order = input(f"What would you like? {items}: ") if order == "off": print("Turning the machine off.") elif order == "report": CoffeeMaker.report() MoneyMachine.report() else: drink = menu.find_drink(order) if CoffeeMaker.is_resource_sufficient(drink): if MoneyMachine.make_payment(drink.cost): CoffeeMaker.make_coffee(drink)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine menu = Menu() coffeeMaker = CoffeeMaker() moneyMachine = MoneyMachine() machine_is_on = True while machine_is_on: choice: str = input(f"What would you like? ({menu.get_items()}): ").lower() if choice == "report": coffeeMaker.report() moneyMachine.report() elif choice == "off": machine_is_on = False else: drink = menu.find_drink(choice) if coffeeMaker.is_resource_sufficient(drink): if moneyMachine.make_payment(drink.cost): coffeeMaker.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)
#Objects that I'm getting from classes: coffee_maker = CoffeeMaker() money_machine = MoneyMachine() menu = Menu() is_on = True while is_on: options = menu.get_items() decision = input(f"What would you like? ({options}): ") if decision == 'off': is_on = False elif decision == 'report': machine_status = coffee_maker.report() machine_money_status = money_machine.report() else: drink = menu.find_drink(decision) enough_resources = coffee_maker.is_resource_sufficient(drink) if enough_resources: #in here we're putting the attribute "cost" assosiated with the "drink" object (which is menu.find_drink(decision)) #which is a menu item. payment_successful = money_machine.make_payment(drink.cost) if payment_successful: coffee_maker.make_coffee(drink)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine barista = CoffeeMaker() menu = Menu() payment = MoneyMachine() is_on = True while is_on: choice = input(f"What would you like? {menu.get_items()}: ") if choice == "off": is_on = False elif choice == "report": barista.report() payment.report() else: drink = menu.find_drink(choice) if barista.is_resource_sufficient(drink) and payment.make_payment( drink.cost): barista.make_coffee(drink)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine menu = Menu() machine = CoffeeMaker() atm = MoneyMachine() coffeeMachine = True while coffeeMachine: coffeeChoice = input("What would you like? (espresso/latte/cappuccino/): ") if coffeeChoice == 'report': machine.report() atm.report() elif coffeeChoice == 'off': coffeeMachine = False else: order = menu.find_drink(coffeeChoice) if not order == None: # Check Resource if machine.is_resource_sufficient(order): # Ask for coins # Check transaction if atm.make_payment(order.cost): # Make coffee machine.make_coffee(order)
# 1. print report # 2. Check resources sufficient? # 3. Process coins # 4. Check transaction successful? # 5. Make Coffee. money_machine = MoneyMachine() coffee_maker = CoffeeMaker() menu = Menu() is_on = True # money_machine.report() # coffee_maker.report() while is_on: options = menu.get_items( ) # list of available items (latte/espresso/cappuccino/) choice = input(f"What would you like? ({options}): ") if choice == "off": is_on = False # shut off elif choice == "report": # get report coffee_maker.report() # report of all resources money_machine.report() # report of current profit else: drink = menu.find_drink(choice) # user's input of drink # check if resource is sufficient (True/False) and if payment is successful (True/False) if coffee_maker.is_resource_sufficient( drink) and money_machine.make_payment(drink.cost): coffee_maker.make_coffee(drink) # make coffee
from menu import Menu from coffee_maker import CoffeeMaker from money_machine import MoneyMachine off = False coffee_menu = Menu() coffee_machine = CoffeeMaker() cash_machine = MoneyMachine() while not off: selection = input("Please select a drink(espresso, latte, cappuccino): ").lower() if selection == "off": off = True elif selection == "report": coffee_machine.report() cash_machine.report() else: drink_check = coffee_menu.find_drink(selection) if drink_check: if coffee_machine.is_resource_sufficient(drink_check): payment = cash_machine.make_payment(drink_check.cost) if payment: coffee_machine.make_coffee(drink_check) cash_machine.money_received = 0
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 my_menu = Menu() my_coffee_machine = CoffeeMaker() my_money_maker_machine = MoneyMachine() my_coffee_machine.report() my_money_maker_machine.report() is_on = True while is_on: menu_options = my_menu.get_items() user_choice = input(f"What drinks do you want? ({menu_options}) ").lower() if user_choice == "off": is_on = False elif user_choice == "report": my_coffee_machine.report() my_money_maker_machine.report() else: drink = my_menu.find_drink(user_choice) if drink is not None: if my_coffee_machine.is_resource_sufficient(drink): if my_money_maker_machine.make_payment(drink.cost): my_coffee_machine.make_coffee(drink)