-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
47 lines (36 loc) · 1.36 KB
/
app.py
File metadata and controls
47 lines (36 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import database
MENU_PROMPT = """
CHoose one of the options:
1- Add a new bean
2- See all beans
3- Find a bean by name
4- See which preparation method is best
5- exit
Your selection:
"""
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')
menu()