Beispiel #1
0
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
Beispiel #2
0
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)
Beispiel #3
0
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)
Beispiel #4
0
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)
Beispiel #5
0
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)
Beispiel #6
0
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)
Beispiel #7
0
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)
Beispiel #8
0
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)
Beispiel #9
0
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)
Beispiel #10
0
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")
Beispiel #11
0
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)
Beispiel #12
0
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)
Beispiel #13
0
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)
Beispiel #14
0
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)
Beispiel #15
0
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)
Beispiel #17
0
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()
Beispiel #18
0
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)
Beispiel #19
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)
Beispiel #20
0
menu = Menu()
cofee_maker = CoffeeMaker()
money_machine = MoneyMachine()

item_list = menu.get_items().split("/")

# remove empty items
while "" in item_list:
    item_list.remove("")

menu_options = ["report", "off"]
menu_options.extend(item_list)
machine_is_on = True

while machine_is_on:
    choice = input(f"What would you like? ({'/'.join(item_list)}): ").lower()
    if choice == "off":
        machine_is_on = False
    elif choice == "report":
        cofee_maker.report()
        money_machine.report()
    elif choice in item_list:
        drink = menu.find_drink(choice)
        if cofee_maker.is_resource_sufficient(drink):
            if money_machine.make_payment(drink.cost):
                cofee_maker.make_coffee(drink)
                money_machine.money_received = 0
    else:
        print("invalid selection")
Beispiel #21
0
    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:
                print('not enough money')
        else:
            print('There is not enough resources in the tank.')
        go_back = input('\nPress enter to go back...)')
    elif option == '2':
        clear()
        machine.report()
        go_back = input('\nPress enter to go back...)')
    elif option == '3':
        machine_on = False
Beispiel #22
0
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)
        
Beispiel #23
0
from menu import Menu, MenuItem
from coffee_maker import CoffeeMaker
from money_machine import MoneyMachine

menu = Menu()
coffee_maker = CoffeeMaker()
money_machine = MoneyMachine()
while True:
    coffee_type = input(f'Please pick your coffee {menu.get_items()} ')
    if coffee_type == 'report':
        coffee_maker.report()
        money_machine.report()
        continue
    coffee_object = menu.find_drink(coffee_type)
    if coffee_object:
        if coffee_maker.is_resource_sufficient(coffee_object):
            charge = coffee_object.cost
            print(f"That'll be ${float(coffee_object.cost)}. ")
            if money_machine.make_payment(charge):
                coffee_maker.make_coffee(coffee_object)
    else:
        continue

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)
Beispiel #25
0
from menu import Menu
from coffee_maker import CoffeeMaker
from money_machine import MoneyMachine

money_machine = MoneyMachine()
coffee_maker = 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":
        coffee_maker.report()
        money_machine.report()
    else:
        drink = menu.find_drink(choice)
        # print(drink)
        is_enough_ingredients = coffee_maker.is_resource_sufficient(drink)
        is_payment_successful = money_machine.make_payment(drink.cost)
        if is_enough_ingredients and is_payment_successful:
            coffee_maker.make_coffee(drink)
Beispiel #26
0
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)

Beispiel #27
0
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)

Beispiel #28
0
is_on = True

# espresso = MenuItem("espresso", 50, 0, 18, 1.5)
# latte = MenuItem("latte", 200, 150, 24, 2.5)
# cappuccino = MenuItem("cappuccino", 250, 100, 24, 3.0)


while is_on:
    options = menu.get_items()
    command = input(f"What would you like today? ({options}): ")

    if command == 'off':
        is_on = False

    elif command == 'report':
        coffee_maker.report()
        money_machine.report()

    else:
        drink = menu.find_drink(command)
        enough_resources = coffee_maker.is_resource_sufficient(drink)
        if enough_resources:
            enough_money = money_machine.make_payment(drink.cost)
            if enough_money:
                coffee_maker.make_coffee(drink)

        # here we could simplify code like
        # if enough_resources and enough_money
        # but logically it is wrong, b'coz even if resources was not enough it will ask for insert money
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")
Beispiel #30
0
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)