Esempio n. 1
0
def menu():
    connection = database.connect()
    database.create_tables(connection)

    while (user_input := input(MENU_PROMPT)) != "5":
        if user_input == "1":
            name = input("Enter your bean name: ")
            method = input("Enter how you've prepared it")
            rating = int(input("Enter your rating score (0-100): "))

            database.add_bean(connection, name, method, rating)

        elif user_input == "2":
            beans = database.get_all_beans(connection)

            for bean in beans:
                print(f"{bean[1]}{bean[2]}{bean[3]}")

        elif user_input == "3":
            name = input("Enter bean name to find: ")
            beans = database.get_beans_by_name(connection, name)

            for bean in beans:
                print(f"{bean[1]}{bean[2]}{bean[3]}")

        elif user_input == "4":
            name = input("Enter bean name to find: ")
            best_method = database.get_best_preparation_for_bean(connection, name)

            print(f"The best preparation method for {name} is {best_method[2]}")
        elif user_input == "5":
            pass
        else:
            pass
Esempio n. 2
0
def menu():
    connection = database.connect()
    database.create_tables(connection)

    user_input = input(MENU_PROMPT)
    while (user_input != "5"):
        if user_input == '1':
            name = input('ENter bean name: ')
            method = input('Enter how you' 've prepared: ')
            rating = int(input('Enter rating score (0-100): '))

            databse.add_bean(connection, name, method, rating)

        elif user_input == '2':
            beans = database.get_all_beans(connection)
            for bean in beans:
                print(f"{bean[1]} ({bean[2]}) - {bean[3]}/100")

        elif user_input == '3':
            name = input('Enter bean name to find: ')
            beans = database.get_beans_by_name(connection, name)
            for bean in beans:
                print(f"{bean[1]} ({bean[2]}) - {bean[3]}/100")

        elif user_input == '4':
            name = input('Enter bean name to find: ')
            best_method = database.get_best_preparation(connection, name)
            print(f"the best preparation for {name} is: {best_methof[2]}")

        else:
            print('Invalid Input')
Esempio n. 3
0
def menu():
    connection = database.connect()
    database.create_tables(connection)

    user_input = input(MENU_PROMPT)

    while (user_input != "5"):

        if user_input == "1":
            name = input("Enter bean name: ")
            method = input("Ender how you prepared it: ")
            rating = int(input("Enter score (0-100): "))

            database.add_bean(connection, name, method, rating)
        elif user_input == "2":
            beans = database.get_all_beans(connection)
            for bean in beans:
                print(f"{bean[1]} ({bean[2]}) - {bean[3]}/100")
        elif user_input == "3":
            name = input("Enter bean name: ")
            beans = database.get_beans_by_name(connection, name)
            for bean in beans:
                print(f"{bean[1]} ({bean[2]}) - {bean[3]}/100")
        elif user_input == "4":
            name = input("Enter bean name: ")
            best_method = database.get_best_preparation_for_bean(
                connection, name)

            print(
                f"The best preparation method for {name} is : {best_method[2]}"
            )
        else:
            print("Invalid input or exit. Try again :)")

        user_input = input(MENU_PROMPT)
Esempio n. 4
0
def menu():

    connection = connect()
    create_table(connection)
    user_input = input(MENU_PROMPT)
    while user_input != "5":

        if user_input == "1":
            name = input("Enter Bean Name: ")
            method = input("Enter How you've Prepared It: ")
            rating = int(input("Enter Your Rating Score: "))

            add_bean(connection, name, method, rating)
        elif user_input == "2":
            beans = get_all_beans(connection)

            for bean in beans:
                print(f"{bean[1]} {bean[2]} {bean[3]}")

        elif user_input == "3":
            name = input("Enter bean Name to find: ")
            beans = get_beans_by_name(connection, name)

            for bean in beans:
                print(f"{bean[1]} {bean[2]} {bean[3]}")
        elif user_input == "4":
            name = input("Enter Bean name to find: ")
            best_method = get_preparation_for_beans(connection, name)

            print(
                f"The Best Preparation method for {name} is: {best_method[2]}")

        user_input = input(MENU_PROMPT)
    def test_get_multiple_beans_by_name(self):
        database.create_tables(self.connection)
        database.add_bean(self.connection, "Test Bean", "Percolator", 100)
        database.add_bean(self.connection, "Test Bean", "Espresso", 80)
        beans = database.get_beans_by_name(self.connection, "Test Bean")

        self.assertEqual(beans[0][1], "Test Bean")
        self.assertEqual(beans[1][1], "Test Bean")
        self.assertEqual(beans[0][2], "Percolator")
        self.assertEqual(beans[1][2], "Espresso")
Esempio n. 6
0
def menu():
    connection=database.connect()
    database.create_tables(connection)
    # user_input=input(MENU_PROMPT)
    while (user_input :=input(MENU_PROMPT))!='5':
        if user_input=='1':
            name,method,rating=input('please enter name,method and rating(between 0-100) resp').split(",")
            database.add_bean(connection, name, method, int(rating))
        elif user_input=='2':
            beans=database.get_all_beans(connection)
            for bean in beans:
                print(bean)
        elif user_input=='3':
            name=input('enter name u want to find')
            bin=database.get_beans_by_name(connection, name)
            print(bin)
        elif user_input=='4':
            name=input('enter name u want to get')
            name=database.get_best_prep_for_bean(connection, name)
            print(name)
        else:
            print('invalid input')
Esempio n. 7
0
def prompt_find_bean(connection):
    name = input("Enter bean name to find: ")
    beans = database.get_beans_by_name(connection, name)

    for bean in beans:
        print(f"{bean[1]} {bean[2]} - {bean[3]}/ 100")