Exemple #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
Exemple #2
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)
Exemple #3
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)
Exemple #4
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)
Exemple #5
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)
Exemple #6
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)
Exemple #7
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)
Exemple #8
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)
Exemple #9
0
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()
Exemple #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")
Exemple #11
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)
Exemple #12
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)
Exemple #13
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)
Exemple #14
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)
Exemple #16
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)
Exemple #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()
Exemple #18
0
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())
Exemple #19
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)
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)
Exemple #21
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)
Exemple #22
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
Exemple #23
0
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, 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)
Exemple #25
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)
        
Exemple #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)

from menu import Menu, MenuItem
from coffee_maker import CoffeeMaker
from money_machine import MoneyMachine

menu = Menu()
menu_item = MenuItem()
coffee = CoffeeMaker()
money = MoneyMachine()

cost = 0
while True:
    flag = 0
    choice = input("What would you like? (espresso/latte/cappuccino): ").lower()
    if choice == "report":
        coffee.report()
    elif choice == "off":
        break
    else:
        if coffee.is_resource_sufficient(choice):
            continue
        y = money.process_coins()
        if money.make_payment():
            continue
        else:
            coffee.make_coffee(menu_item)
Exemple #28
0
#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"))
Exemple #29
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)
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")