@@ -35,48 +35,63 @@ class Brand(Enum):
35
35
UNDEFINED = auto ()
36
36
37
37
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 :
39
48
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 } ]"
41
55
42
56
def __repr__ (self ) -> str :
43
57
return self .__str__ ()
44
58
45
59
46
- class Cloth :
60
+ class Cloth ( Reflector ) :
47
61
name = ""
48
- brand : Brand
49
-
50
-
51
- class Skirt (Cloth ):
52
- name = "Skirt"
53
-
62
+ type : Type
54
63
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
57
68
58
69
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 ):
68
71
size : Size
69
72
color : Color
70
73
74
+ def __init__ (self , size : Size , color : Color ) -> None :
75
+ super ().__init__ ()
76
+ self .size = size
77
+ self .color = color
78
+
71
79
72
- class Product :
80
+ class Product ( Reflector ) :
73
81
cloth : Cloth
74
82
variant : Variant
83
+ brand : Brand
75
84
76
85
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
+ }
79
94
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