from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine # create an object class moneyMachine: money_machine = MoneyMachine () coffee_maker = CoffeeMaker() coffee_maker.report() # an object call a method : money_machine.report()
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine coffee_maker = CoffeeMaker() menu = Menu() cash_register = MoneyMachine() menu_items = menu.get_items() def main(): option = input(f"What would you like? ({menu_items}) ") if option == 'off': exit() elif option == 'report': coffee_maker.report() cash_register.report() main() else: order = menu.find_drink(option) if not order: main() else: if not coffee_maker.is_resource_sufficient(order): main() else: if not cash_register.make_payment(order.cost): main()
# TODO: From Module Import Classes from menu import Menu from coffee_maker import CoffeeMaker from money_machine import MoneyMachine # TODO: Create Objects by initiating the Imported Classes menu = Menu() coffee_maker = CoffeeMaker() money_machine = MoneyMachine() is_on = True while is_on: # TODO: Get Options and prompt user for input options = menu.get_items() user_choice = input(f"What would you like? {options} ") if user_choice == 'report': coffee_maker.report() money_machine.report() elif user_choice == 'off': is_on = False else: # TODO: drink = menu.find_drink(user_choice) if coffee_maker.is_resource_sufficient(drink): if money_machine.make_payment(drink.cost): coffee_maker.make_coffee(drink)
from coffee_maker import CoffeeMaker from menu import Menu, MenuItem from money_machine import MoneyMachine coffemaker = CoffeeMaker() coffemaker.report() my_menu = Menu() money_machine = MoneyMachine() while True: print(f"Hi, what would you like {my_menu.get_items()}?") userInput = input() if userInput == "off": break elif userInput == "report": coffemaker.report() else: drink = my_menu.find_drink(userInput) if isinstance(drink, MenuItem): if coffemaker.is_resource_sufficient(drink): coffemaker.make_coffee(drink) del drink
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine my_money_machine = MoneyMachine() coffe_maker = CoffeeMaker() my_menu = Menu() is_on = True while is_on: option = my_menu.get_items() user_choice = input(f"Choose one from the menu ({option}): ") if user_choice == "off": is_on = False elif user_choice == "report": coffe_maker.report() my_money_machine.report() else: drink = my_menu.find_drink(user_choice) if coffe_maker.is_resource_sufficient(drink) and my_money_machine.make_payment(drink.cost): coffe_maker.make_coffee(drink)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine cash_register = MoneyMachine() coffee_maker = CoffeeMaker() menu = Menu() on = True while on: options = menu.get_items() choix = input(f"What'll it be? {options}") if choix == 'off': on = False elif choix == 'report': cash_register.report() coffee_maker.report() else: drink = menu.find_drink(choix) enough_stuff = coffee_maker.is_resource_sufficient(drink) enough_money = cash_register.make_payment(drink.cost) if enough_stuff and enough_money: coffee_maker.make_coffee(drink)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine coffee = CoffeeMaker() money = MoneyMachine() menu = Menu() while True: order = input(f"What would you like? ({menu.get_items()}): ") if order == 'report': coffee.report() money.report() elif order == 'off': exit() else: valid_menu_item = menu.find_drink(order) if valid_menu_item is not None: make_cup = coffee.is_resource_sufficient(valid_menu_item) if make_cup: transaction = money.make_payment(valid_menu_item.cost) if transaction: coffee.make_coffee(valid_menu_item)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine menu = Menu() coffee_maker = CoffeeMaker() money_machine = MoneyMachine() is_on= True while is_on: options = menu.get_items() user_choice = input(f"What would you like? {options}").lower() if user_choice == "exit": is_on = False elif user_choice == "report": coffee_maker.report() money_machine.profit() else: drink = menu.find_drink(user_choice) if coffee_maker.is_resource_sufficient(drink): if (money_machine.make_payment(drink.cost)): coffee_maker.make_coffee(drink)
# prompt user choice = input(f"What would you like? {menu.get_items()}: ") # turn off cofee machine with off command if choice == "off": print("Turning coffee machine off\n") machine_on = False # print report elif choice == "report": coffeemaker.report() # Check for sufficient resources elif menu.find_drink(choice) != None: drink = menu.find_drink(choice) if coffeemaker.is_resource_sufficient(drink): # process coins if moneymachine.make_payment(drink.cost): #process transaction (enough money, make change, update coinbox) coffeemaker.make_coffee(drink) machine_on = True coin_box = 0 # instantiate objects menu = Menu() coffeemaker = CoffeeMaker() moneymachine = MoneyMachine() while machine_on: run()
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)
from menu import Menu from coffee_maker import CoffeeMaker from money_machine import MoneyMachine my_menu = Menu() my_coffee_maker = CoffeeMaker() my_money_machine = MoneyMachine() is_machine_on = True while is_machine_on: command = input(f"What do you want to order? ({my_menu.get_items()})") if command == "report": my_coffee_maker.report() my_money_machine.report() elif command == "off": is_machine_on = False else: order = my_menu.find_drink(command) if order is None: continue if not my_coffee_maker.is_resource_sufficient(order): continue if not my_money_machine.make_payment(order.cost): continue my_coffee_maker.make_coffee(order) input("Enter to continue")
from menu import Menu from coffee_maker import CoffeeMaker from money_machine import MoneyMachine obj_coffee_maker = CoffeeMaker() obj_menu = Menu() obj_money_machine = MoneyMachine() is_machine_on = True while is_machine_on: command = input(f"What would you like? {obj_menu.get_items()}: ") if command == "report": obj_coffee_maker.report() elif command == "off": is_machine_on = False else: drink = obj_menu.find_drink(command) if drink is not None: if obj_coffee_maker.is_resource_sufficient(drink): if obj_money_machine.make_payment(drink.cost): obj_coffee_maker.make_coffee(drink)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine coin_bot = MoneyMachine() java_machina = CoffeeMaker() get_bot = Menu() system_on = True while system_on: selection = get_bot.get_items() choice = input(f"Please make a selection {selection}: ") if choice == "off": system_on = False elif choice == "report": java_machina.report() coin_bot.report() else: drink = get_bot.find_drink(choice) if java_machina.is_resource_sufficient(drink): if coin_bot.make_payment(drink.cost): java_machina.make_coffee(drink)
################################### # # 100 Days of code bootcamp 2021 # (Udemy course by Angela Yu) # # Day 16 project - Christopher Hagan # ################################### from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine drinks_menu = Menu() drinks_maker = CoffeeMaker() transaction_handler = MoneyMachine() on = True while on: user_choice = input('What would you like to drink ({})?: '.format( drinks_menu.get_items())).lower() if user_choice in ['report', 'off'] or drinks_menu.find_drink(user_choice): if user_choice == 'off': # Handle secret keyword 'off' on = False elif user_choice == 'report': # Handle secret keyword 'report' drinks_maker.report() transaction_handler.report() else:
def __init__(self): self.money_machine = MoneyMachine() self.coffee_maker = CoffeeMaker() self.menu = Menu()
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine coffee_menu = Menu() coffees = coffee_menu.get_items() coffee_maker = CoffeeMaker() money_machine = MoneyMachine() machine_on = True while machine_on: order = input(f"What would you like? {coffees}\n") if order == "off": machine_on = False elif order == "report": coffee_maker.report() else: coffee = coffee_menu.find_drink(order) if coffee is not None: can_make = coffee_maker.is_resource_sufficient(coffee) if can_make: payment_successful = money_machine.make_payment(coffee.cost) if payment_successful: coffee_maker.make_coffee(coffee)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine # menu_item=MenuItem() menu_of_coffee=Menu() making_coffee=CoffeeMaker() machine_with_money=MoneyMachine() is_on = True while is_on : options = menu_of_coffee.get_items() name_of_coffee = input(f"Which type of coffee do you want ({options}): \n").lower() if name_of_coffee=="off": is_on=False elif name_of_coffee == "report": making_coffee.report() machine_with_money.report() else : drink=menu_of_coffee.find_drink(name_of_coffee) if making_coffee.is_resource_sufficient(drink) and machine_with_money.make_payment(drink.cost): making_coffee.make_coffee(drink)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine maker = CoffeeMaker() mm = MoneyMachine() menu = Menu() print("Welcome to the virtual coffee machine!") while True: prompt = "Type your choice. (" + menu.get_items() + "): " choice = input(prompt) item = menu.find_drink(choice) if item == None: continue sufficient = maker.is_resource_sufficient(item) if not sufficient: mm.report() break payment = mm.make_payment(item.cost) if not payment: continue maker.make_coffee(item) mm.report()
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine turn_off = False coffee_machine = CoffeeMaker() money_machine = MoneyMachine() menu = Menu() while not turn_off: user_input = input(f"What would you like? ({menu.get_items()}): ") if user_input == "off": turn_off = True elif user_input == "report": coffee_machine.report() money_machine.report() else: order = menu.find_drink(user_input) if coffee_machine.is_resource_sufficient( order) and money_machine.make_payment(order.cost): coffee_machine.make_coffee(order)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine menu = Menu() coffee_maker = CoffeeMaker() money = MoneyMachine() time_break = True while time_break: choice = input(f"What drink would you like? {menu.get_items()}") if choice == "off": print("Machine powering off...") time_break = False elif choice == "report": coffee_maker.report() money.report() else: if coffee_maker.is_resource_sufficient( menu.find_drink(choice)) and money.make_payment( menu.find_drink(choice).cost): coffee_maker.make_coffee(menu.find_drink(choice))
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine menu = Menu() #menu_item = MenuItem() c_maker = CoffeeMaker() vend = MoneyMachine() is_on = True # TODO Print Report vend.report() c_maker.report() # TODO Check Resources Sufficient # TODO Process Coins # TODO Check Transaction Successful # TODO Make Coffee while is_on: options = menu.get_items() choice = input(f"What would you like ({options}: ") if choice == "off": is_on = False elif choice == "report": c_maker.report() vend.report() else:
# from prettytable import PrettyTable # table = PrettyTable() # table.add_column("Pokemon Name", ["Pikachu", "Squire", "Charmane"]) # table.add_column("Type", ["Electric", "Water", "Fire"]) # # table.align = "l" # # print(table) # A Coffee Machine Project... from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine money_machine = MoneyMachine() coffee_maker = CoffeeMaker() menu = Menu() is_on = True coffee_maker.report() money_machine.report() 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()
from menu import Menu from coffee_maker import CoffeeMaker from money_machine import MoneyMachine #Print Report #Check resources is_resource_sufficient #Process Coins #Check transaction is succesful #Make Coffee coffee_maker = CoffeeMaker() menu = Menu() 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) is_resource_sufficient = coffee_maker.is_resource_sufficient(drink) is_payment_succesful = money_machine.make_payment(drink.cost) if is_payment_succesful and is_resource_sufficient: coffee_maker.make_coffee(drink)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine mn = Menu() cm = CoffeeMaker() mon = MoneyMachine() con = True while (con): options = mn.get_items() inp = input(f"Which drink do you want {options} :") if inp == 'report': cm.report() mon.report() elif inp == 'off': con = False else: drink = mn.find_drink(inp) is_enough_ingredients = cm.is_resource_sufficient(drink) is_payment_successful = mon.make_payment(drink.cost) if is_enough_ingredients and is_payment_successful: cm.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 def print_report(): coffee_maker.report() money_machine.report() while is_on: choice = input(f"What would you like? ({menu.get_items()})") if choice == "off": is_on = False elif choice == "report": print_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() coffeeMaker = CoffeeMaker() moneyMachine = MoneyMachine() makeCoffee = True while makeCoffee: order = input(f"Enter your order ({menu.get_items()}): ") if order == "report": coffeeMaker.report() moneyMachine.report() elif order == "off": makeCoffee = False else: drink = menu.find_drink(order) if drink is not None: menuItem = MenuItem(drink.name, drink.cost, drink.ingredients["water"], drink.ingredients["milk"], drink.ingredients["coffee"]) if coffeeMaker.is_resource_sufficient(drink): print("Please enter coins.") if moneyMachine.make_payment(menu.find_drink(order).cost): coffeeMaker.make_coffee(menu.find_drink(order))
############################################# My solution ##################################### from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine # latte = MenuItem("latte", 100, 80, 15, 1.5) # espresso = MenuItem("espresso", 60, 0, 20, 2.5) # cappuccino = MenuItem("cappuccino", 200, 150, 40, 4.5) machine_resources = CoffeeMaker() products = Menu() money = MoneyMachine() turn_off = False while not turn_off: order = input(f"What would you like? {products.get_items()}: ") if order == 'report': machine_resources.report() money.report() elif order == 'off': turn_off = True else: user_order = products.find_drink(order) if machine_resources.is_resource_sufficient( user_order) and money.make_payment(user_order.cost): machine_resources.make_coffee(user_order) ############################################## Angela's solution ############################################### # from menu import Menu # from coffee_maker import CoffeeMaker # from money_machine import MoneyMachine
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine is_on = True drinks_menu = Menu() coffe_machine = CoffeeMaker() moneybox = MoneyMachine() while is_on: text = input(f"What would you like? {drinks_menu.get_items()}:").lower() if text == 'off': is_on = False elif text == 'report': coffe_machine.report() moneybox.report() else: drink = drinks_menu.find_drink(text) if(drink): if(coffe_machine.is_resource_sufficient(drink)): if(moneybox.make_payment(drink.cost)): coffe_machine.make_coffee(drink) # example change
from menu import MenuItem, Menu from money_machine import MoneyMachine from coffee_maker import CoffeeMaker if __name__ == "__main__": menu_items = Menu() money_handler = MoneyMachine() coffee_maker = CoffeeMaker() is_on = True while is_on: order = input( f"What would you like to have {menu_items.get_items()}::") if order == "off": is_on = False elif order == "report": money_handler.report() coffee_maker.report() else: order_details = menu_items.find_drink(order) if order_details and coffee_maker.is_resource_sufficient( order_details) and money_handler.make_payment( order_details.cost): coffee_maker.make_coffee(order_details)
from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine coffee_machine = CoffeeMaker() coffee_menu = Menu() money_machine = MoneyMachine() operationOver = False while not operationOver: print(coffee_menu.get_items()) user_command = input( "Select the drink from the menu or type 'report' to issue a report ") if user_command == 'report': print(coffee_machine.report(), money_machine.report()) else: menu_item_choice = coffee_menu.find_drink(user_command) # if there are enough resources and the user made enough payment we dispense the drink if coffee_machine.is_resource_sufficient( menu_item_choice) and money_machine.make_payment( menu_item_choice.cost): coffee_machine.make_coffee(menu_item_choice)