-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
mouredev.py
74 lines (54 loc) · 1.37 KB
/
mouredev.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
from enum import Enum
"""
Ejercicio
"""
class Weekday(Enum):
MONDAY = 1
TUESDAY = 2
WEDNESDAY = 3
THURSDAY = 4
FRIDAY = 5
SATURDAY = 6
SUNDAY = 7
def get_day(number: int):
print(Weekday(number).name)
get_day(1)
get_day(3)
"""
Extra
"""
class OrderStatus(Enum):
PENDING = 1
SHIPPED = 2
DELIVERED = 3
CANCELLED = 4
class Order:
status = OrderStatus.PENDING
def __init__(self, id) -> None:
self.id = id
def ship(self):
if self.status == OrderStatus.PENDING:
self.status = OrderStatus.SHIPPED
self.display_status()
else:
print("El pedido ya ha sido enviado o cancelado")
def deliver(self):
if self.status == OrderStatus.SHIPPED:
self.status = OrderStatus.DELIVERED
self.display_status()
else:
print("El pedido necesita ser enviado antes de entregarse.")
def cancel(self):
if self.status != OrderStatus.DELIVERED:
self.status = OrderStatus.CANCELLED
self.display_status()
else:
print("El pedido no se puede cancelar ya que ya se ha entregado.")
def display_status(self):
print(f"El estado del pedido {self.id} es {self.status.name}")
order_1 = Order(1)
order_1.display_status()
order_1.deliver()
order_1.ship()
order_1.deliver()
order_1.cancel()