This repository was archived by the owner on Aug 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexercise-general-week-08-012--01.py
More file actions
122 lines (93 loc) · 2.46 KB
/
Copy pathexercise-general-week-08-012--01.py
File metadata and controls
122 lines (93 loc) · 2.46 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
from enum import Enum, auto
# THIS IS NOT THE BEST PRACTICE
# THIS IS JUST FOR TEACHING
class Size(Enum):
FREE_SIZE = auto()
UNDEFUNED = auto()
X_SMALL = auto()
SMALL = auto()
MEDIUM = auto()
LARGE = auto()
X_LARGE = auto()
class Color(Enum):
UNDEFINED = auto()
MULTICOLOR = auto()
BLACK = auto()
BLUE = auto()
GREEN = auto()
YELLOW = auto()
ORANGE = auto()
PURPLE = auto()
GRAY = auto()
class Brand(Enum):
BRAND_A = auto()
BRAND_B = auto()
BRAND_C = auto()
BRAND_D = auto()
BRAND_E = auto()
UNDEFINED = auto()
class Type(Enum):
UNDEFINED = auto()
COAT = auto()
PANTS = auto()
SKIRT = auto()
SHIRT = auto()
HAT = auto()
class Reflector:
def __str__(self) -> str:
V = dir(self)
S = ""
for v in V:
if not v.startswith("__"):
S += f"{self.__getattribute__(v)}, "
return f"[{S[:-2] if len(S)>=2 else S}]"
def __repr__(self) -> str:
return self.__str__()
class Cloth(Reflector):
name = ""
type: Type
def __init__(self, name: str, type: Type) -> None:
super().__init__()
self.name = name
self.type = type
class Variant(Reflector):
size: Size
color: Color
def __init__(self, size: Size, color: Color) -> None:
super().__init__()
self.size = size
self.color = color
class Product(Reflector):
cloth: Cloth
variant: Variant
brand: Brand
def __init__(self, brand: Brand, cloth: Cloth, variant: Color) -> None:
super().__init__()
self.brand = brand
self.cloth = cloth
self.variant = variant
V = {
1001: Variant(Size.FREE_SIZE, Color.BLACK),
1002: Variant(Size.FREE_SIZE, Color.GRAY),
1003: Variant(Size.MEDIUM, Color.BLACK),
1004: Variant(Size.MEDIUM, Color.BLUE),
1005: Variant(Size.X_LARGE, Color.MULTICOLOR),
1006: Variant(Size.X_SMALL, Color.MULTICOLOR),
}
C = {
2001: Cloth("Round", Type.HAT),
2002: Cloth("Cowboy", Type.HAT),
2003: Cloth("Cap", Type.HAT),
2004: Cloth("Long", Type.SHIRT),
2005: Cloth("Long", Type.SKIRT),
}
L = [
Product(Brand.BRAND_A, C[2003], V[1003]),
Product(Brand.BRAND_A, C[2003], V[1004]),
Product(Brand.BRAND_B, C[2004], V[1003]),
Product(Brand.BRAND_B, C[2005], V[1003]),
Product(Brand.BRAND_C, C[2004], V[1005]),
Product(Brand.BRAND_C, C[2005], V[1006]),
]
for product in L:
print(product)