forked from ActoSoft/DjangoCourse-PythonFinalExercise
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestaurante.py
More file actions
181 lines (128 loc) · 5.81 KB
/
restaurante.py
File metadata and controls
181 lines (128 loc) · 5.81 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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import time
global dishes
dishes = []
#DEFINO LOS ATRIBUTOS DEL PLATILLO
class Platillo:
def __init__(self, name, description, recipe, investment, sell, time, kcal):
self.name = name
self.description = description
self.recipe = recipe
self.investment = investment
self.sell = sell
self.time = time
self.kcal = kcal
def create_dish():
name = input('Introduce el platilo nuevo: ')
description = input('Introduce una descripción: ')
recipe = input('Introduce los ingredientes: ')
try:
investment = int(input('Introduce una inversión para realizar el platillo: '))
except ValueError:
print("El valor introducido debe ser un número entero")
investment = int(input('Introduce una inversión para realizar el platillo: '))
try:
sell = int(input('Introduce el precio al público: '))
except ValueError:
print("El valor introducido debe ser un número entero")
sell = int(input('Introduce el precio al público: '))
try:
time = int(input('Introduce el tiempo de preparación(min): '))
except ValueError:
print("El valor introducido debe ser un número entero")
time = int(input('Introduce el tiempo de preparación: '))
try:
kcal = int(input('Introduce las calorías del platillo (cal): '))
except ValueError:
print("El valor introducido debe ser un número entero")
kcal = int(input('Introduce las calorías del platillo: '))
platillo = Platillo(name, description, recipe, investment, sell, time, kcal)
dishes.append(platillo)
def print_dishes():
if dishes == []:
print('No hay platillos disponibles, agrega un platillo')
else:
for dish in dishes:
print (f'Platillo: {dish.name}. Descripción: {dish.description}. Inversión: ${dish.investment} MXN'
f' Venta al público: ${dish.sell} MXN. Ingredientes: {dish.recipe}.'
f' Tiempo de preparación: {dish.time}. Calorías en alimento: {dish.kcal}')
print(f'----------Hasta aquí es el menú para el platillo: {dish.name}--------')
def get_dish():
if dishes == []:
print('No hay platillos disponibles, agrega un platillo')
else:
user_dish = input('Ingresa el platillo a buscar: ')
for dish in dishes:
if user_dish in dish.name:
print (f'Platillo: {dish.name}. Descripción: {dish.description}. Inversión: ${dish.investment} MXN'
f'Venta al público: ${dish.sell} MXN. Ingredientes: {dish.recipe}.'
f'Tiempo de preparación: {dish.time}. Calorías en alimento: {dish.kcal}')
else:
print('No hay platillo existente con ese nombre')
def edit_dish():
if dishes == []:
print('No hay platillos disponibles, agrega un platillo')
else:
user_dish = input('Ingresa el platillo a editar: ')
for dish in dishes:
if user_dish in dish.name:
user_edit = int(input('¿Qué apartado desea editar?'
'1. Descripcion 2. Inversion 3. Venta 4. Ingredientes'
'5. Tiempo 6. Calorias: '))
if user_edit == 1:
user_descript = input('Ingresa la nueva descripción: ')
dish.description = user_descript
print('Cambio exitoso')
elif user_edit == 2:
user_invest = input('Ingresa la nueva inversión: ')
dish.investment = user_invest
print('Cambio exitoso')
elif user_edit == 3:
user_sell = input('Ingresa el nuevo precio al público: ')
dish.sell = user_sell
print('Cambio exitoso')
elif user_edit == 4:
user_recipe = input('Ingresa los ingredientes: ')
dish.recipe = user_recipe
print('Cambio exitoso')
elif user_edit == 5:
user_time = input('Ingresa el nuevo tiempo: ')
dish.time = user_time
print('Cambio exitoso')
elif user_edit == 6:
user_kcal = input('Ingresa las nuevas calorías: ')
dish.kcal = user_kcal
print('Cambio exitoso')
else:
print('Esa opción no se encuentra disponible')
def erase_dish():
user_dish = input('Ingresa el platillo a eliminar: ')
for i, dish in enumerate(dishes):
if dish.name == user_dish:
del dishes[i]
print('Se ha borrado con éxito')
else:
print('El platillo no existe')
def menu():
print('Seleciona las siguientes opciones:\n 1. Ver platillos disponibles\n'
' 2. Buscar platillos por nombre\n 3. Crear nuevo platillo\n'
' 4. Editar platillo existente\n 5. Eliminar platillo\n 6. Salir del programa\n')
user = int(input("Selecciona tu opción [1-6]: "))
while user != 6:
if user == 1:
print_dishes()
elif user == 2:
get_dish()
elif user == 3:
create_dish()
elif user == 4:
edit_dish()
elif user == 5:
erase_dish()
time.sleep(3)
print('Seleciona las siguientes opciones:\n 1. Ver platillos disponibles\n'
' 2. Buscar platillos por nombre\n 3. Crear nuevo platillo\n'
' 4. Editar platillo existente\n 5. Eliminar platillo\n 6. Salir del programa\n')
user = int(input("Selecciona tu opción [1-6]: "))
else:
print('Hasta pronto')
menu()