Skip to content
This repository was archived by the owner on Aug 11, 2023. It is now read-only.

Commit 22af9d7

Browse files
committed
Update
1 parent f834e85 commit 22af9d7

File tree

1 file changed

+41
-26
lines changed

1 file changed

+41
-26
lines changed

lessons/python/exercises/exercise-general-week-08-012--01.py

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,48 +35,63 @@ class Brand(Enum):
3535
UNDEFINED = auto()
3636

3737

38-
class Reflect:
38+
class Type(Enum):
39+
UNDEFINED: auto()
40+
COAT: auto()
41+
PANTS: auto()
42+
SKIRT: auto()
43+
SHIRT: auto()
44+
HAT: auto()
45+
46+
47+
class Reflector:
3948
def __str__(self) -> str:
40-
V=vars(self)
49+
V = dir(self)
50+
S = ""
51+
for v in V:
52+
if not v.startswith("__"):
53+
S += v+", "
54+
return f"[{S[:-2] if len(S)>=2 else S}]"
4155

4256
def __repr__(self) -> str:
4357
return self.__str__()
4458

4559

46-
class Cloth:
60+
class Cloth(Reflector):
4761
name = ""
48-
brand: Brand
49-
50-
51-
class Skirt(Cloth):
52-
name = "Skirt"
53-
62+
type: Type
5463

55-
class Hat(Cloth):
56-
name = "Hat"
64+
def __init__(self, name: str, type: Type) -> None:
65+
super().__init__()
66+
self.name = name
67+
self.type = type
5768

5869

59-
class Pants(Cloth):
60-
name = "Pants"
61-
62-
63-
class Coat(Cloth):
64-
name = "Coat"
65-
66-
67-
class Variant:
70+
class Variant(Reflector):
6871
size: Size
6972
color: Color
7073

74+
def __init__(self, size: Size, color: Color) -> None:
75+
super().__init__()
76+
self.size = size
77+
self.color = color
78+
7179

72-
class Product:
80+
class Product(Reflector):
7381
cloth: Cloth
7482
variant: Variant
83+
brand: Brand
7584

7685

77-
class Products:
78-
collection: list(Product)
86+
V = {
87+
1001: Variant(Size.FREE_SIZE,Color.BLACK),
88+
1002: Variant(Size.FREE_SIZE,Color.GRAY),
89+
1003: Variant(Size.MEDIUM,Color.BLACK),
90+
1004: Variant(Size.MEDIUM,Color.BLUE),
91+
1005: Variant(Size.X_LARGE,Color.MULTICOLOR),
92+
1006: Variant(Size.X_SMALL,Color.MULTICOLOR),
93+
}
7994

80-
@classmethod
81-
def add(cls, name: str, size: list[Size], brand: Brand, color: Color, count: int):
82-
cloth
95+
C= {
96+
2001:Cloth("Round Hat",Type.HAT)
97+
}

0 commit comments

Comments
 (0)