-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
161 lines (136 loc) · 5.1 KB
/
main.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import food_itens as fi
import day_meals as dm
foodClass = fi.FoodItem()
dayMealsClass = dm.DayMeals()
def main():
b = True
while(b):
print("MENU")
option = int(input("1 - Adicionar Componente? \n2 - Cadastrar Refeição? \n3 - Visualiazar resumo do dia? \n4 - Visualizar resumo de todos os dias?\n5 - Visualizar resumo por refeição \n6 - Sair>"))
if (option == 1):
first = True
while True:
if first:
addItem()
first = False
else:
if input("Mais 1?: S/N: ").upper() == "S":
addItem()
else:
break
elif (option == 2):
resp = addMeal()
if resp:
b = False
elif (option == 3):
resp = choose_day()
showDayResume(resp)
elif (option == 4):
showAllDayResume()
elif (option == 5):
showMealResume()
elif (option == 6):
print("Thanks")
break
def addMeal():
day = choose_day()
meal = choose_meal()
response = False
if meal:
print("Beleza, agora vamos preencher os intens.\n")
ingredients = {}
f = True
while f:
ingredientName = input("Nome: ")
if foodClass.getItem(ingredientName) == False:
resp = input("Nao achamos esse item aqui na base!\n Deseja adiconar? (s/n) ")
if resp.lower() == 's':
addItem()
print("Ok, pode tentar novamente")
continue
elif resp.lower() == 'n':
return False
ingredientQtd = input("Quantidade (g): " )
if float(ingredientQtd) % 2 == 0:
ingredientQtd = int(ingredientQtd)
else:
ingredientQtd = float(ingredientQtd)
# validar ingrediente
ingredients[ingredientName] = ingredientQtd
resp = input("\noutro? (S/N) -> ")
if resp.lower() == 'n':
f = False
response = False
if not response:
dayMealsClass.addDayMeal(meal,ingredients,day)
return response
def addItem():
print("New Item")
name = input("Name: ")
properties = {}
properties["carbohydrate"] = float(input("carbs g/(100g): "))
properties["protein"] = float(input("protein g/(100g): "))
properties["energy"] = int(input("energy kcal/(100g): "))
properties["sodium"] = float(input("sodium mg/(100g): "))
properties["fibre"] = int(input("fibre g/(100g): "))
properties["lipid"] = int(input("lipid g/(100g): "))
foodClass.create(name.lower(), properties)
def showDayResume(date=None):
#if not day: day = str(date.today())
print("\n")
response = dayMealsClass.getAmountPropertiesByDay(date)
print("---------------------------------------------------------------\n")
print ("---- {} ----".format(date))
print('Cafe da manha:')
show_properties(response['beakfast'])
print('Almoco:')
show_properties(response['lunch'])
print('Lanche:')
show_properties(response['afternoon-snack'])
print('Jantar:')
show_properties(response['dinner'])
print('Total:')
show_properties(response['total'])
print("---------------------------------------------------------------")
def showMealResume():
day= choose_day("da refeicao ")
mealName = choose_meal()
meals = dayMealsClass.getMealsByDay(day)
meal_info = dayMealsClass.getAmountPropertiesByMeal(meals[mealName])
show_properties(meal_info)
def choose_day(plus=""):
resp = input("Me diz, voce deseja visualizar o resumo {} de hoje? (s/n) \n>".format(plus))
if resp.lower() == 's':
resp = None
elif resp.lower() == 'n':
resp = input("\nok, entao me diz o dia certinho .... (AAAA-MM-DD)\n>")
return resp
def choose_meal():
op = False
while not op:
op = input("\n 1- Cafe da Manha\n 2- Almoço\n 3- Lanchinho\n 4- Janta\n>")
op = int(op)
meal = None
if op == 1:
meal = "breakfast"
elif op == 2:
meal = "lunch"
elif op == 3:
meal = "afternoon-snack"
elif op == 4:
meal = "dinner"
else:
print("\nopção invalida, tente de novo")
op = False
return meal
def show_properties(meal):
# todo -> move properties to day_meals and put the properties in food_item like a array
print(' carbs: {}g\n prot: {}g\n energia: {}kcal\n sodio: {}mg\n lipidios: {}g\n fibras: {}g\n'.format(meal['carbohydrate'],meal['protein'],meal['energy'],meal['sodium'],meal['lipid'],meal['fibre']))
def showAllDayResume():
resume = dayMealsClass.getAllDaysResume()
print(resume)
for key in list(resume.keys()):
print('DIA %s: \ndata: %s\nmacros:'%( key, resume[key]["date"]))
show_properties(resume[key]["total"])
if __name__ == '__main__':
main()