Skip to content

Commit f4dadaf

Browse files
feat: Diagrmas
1 parent 38db475 commit f4dadaf

File tree

6 files changed

+406
-0
lines changed

6 files changed

+406
-0
lines changed
Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
---
2+
config:
3+
theme: default
4+
themeVariables:
5+
primaryColor: "#1f77b4"
6+
primaryTextColor: "#2d3436"
7+
primaryBorderColor: "#2d3436"
8+
lineColor: "#2d3436"
9+
secondaryColor: "#ffffff"
10+
flowchart:
11+
diagramPadding: 20
12+
nodeSpacing: 50
13+
rankSpacing: 50
14+
defaultRenderer: elk
15+
curve: ortho
16+
---
17+
classDiagram
18+
class K2434232_Pizza {
19+
-List[str] crusts
20+
-List[str] sauces
21+
-List[str] toppings
22+
-List[str] cheeses
23+
-str packaging
24+
-Price price
25+
+str __str__()
26+
+float calculate_price()
27+
+static Pizza from_string(str)
28+
+float set(List, List, List, bool)
29+
+List[str] crusts
30+
+List[str] sauces
31+
+List[str] toppings
32+
+List[str] cheeses
33+
+str packaging
34+
+float price_total
35+
}
36+
37+
class K2434232_User {
38+
-int user_id_counter
39+
-int user_id
40+
-str username
41+
-str password
42+
-str email
43+
-Dict[Pizza, int] ordered_combinations
44+
-List[Loyalty] loyalty_collection
45+
+void add_order(Pizza)
46+
+int get_order_count(Pizza)
47+
+List[Pizza] get_popular_orders()
48+
+str get_username()
49+
+str get_password()
50+
+str get_email()
51+
+int get_loyalty()
52+
}
53+
54+
class K2434232_Order {
55+
-User user
56+
-OrderState state
57+
-List[OrderObserver] observers
58+
-str order_id
59+
-Pizza pizza
60+
-Payment payment
61+
+void attach(OrderObserver)
62+
+void detach(OrderObserver)
63+
+void notify_observers(str)
64+
+void process_order()
65+
+void set_state(OrderState)
66+
}
67+
68+
class K2434232_Payment {
69+
-Price amount
70+
-User user
71+
-PaymentStrategy strategy
72+
-bool use_loyalty
73+
+bool process_payment(bool)
74+
+void set_strategy(PaymentStrategy)
75+
+float calculate_discount()
76+
}
77+
78+
class K2434232_PizzaBuilder {
79+
-Pizza pizza
80+
-int quantity
81+
+PizzaBuilder set_crusts(List[str])
82+
+PizzaBuilder set_sauces(List[str])
83+
+PizzaBuilder set_toppings(List[str])
84+
+PizzaBuilder set_cheeses(List[str])
85+
+PizzaBuilder set_packaging(str)
86+
+List[str] get_crusts()
87+
+List[str] get_sauces()
88+
+List[str] get_toppings()
89+
+List[str] get_cheeses()
90+
+str get_packaging()
91+
+Pizza build()
92+
}
93+
94+
class K2434232_OrderState {
95+
<<abstract>>
96+
+void next_state(Order)*
97+
+str get_state_name()*
98+
}
99+
100+
class K2434232_PlacedState {
101+
+void next_state(Order)
102+
+str get_state_name()
103+
}
104+
105+
class K2434232_PreparingState {
106+
+void next_state(Order)
107+
+str get_state_name()
108+
}
109+
110+
class K2434232_BakingState {
111+
+void next_state(Order)
112+
+str get_state_name()
113+
}
114+
115+
class K2434232_DeliveredState {
116+
+void next_state(Order)
117+
+str get_state_name()
118+
}
119+
120+
class K2434232_OrderObserver {
121+
<<interface>>
122+
+void update(str, str, OrderState)*
123+
}
124+
125+
class K2434232_CustomerNotifier {
126+
+void update(str, str, OrderState)
127+
-void send_notification(str)
128+
}
129+
130+
class K2434232_KitchenDisplay {
131+
+void update(str, str, OrderState)
132+
-void update_display(str)
133+
}
134+
135+
class K2434232_PaymentStrategy {
136+
<<interface>>
137+
+bool process(Price)*
138+
+void validate_payment()*
139+
}
140+
141+
class K2434232_CreditCardStrategy {
142+
-str card_number
143+
-str cvv
144+
+bool process(Price)
145+
+void validate_payment()
146+
}
147+
148+
class K2434232_PayPalStrategy {
149+
-str email
150+
+bool process(Price)
151+
+void validate_payment()
152+
}
153+
154+
class K2434232_DigitalWalletStrategy {
155+
+bool process(Price)
156+
+void validate_payment()
157+
}
158+
159+
class K2434232_PizzaDecorator {
160+
#PizzaBuilder builder
161+
+Pizza apply()*
162+
}
163+
164+
%% Extra Cheese Decorator
165+
class K2434232_ExtraCheeseDecorator {
166+
-int factor_of_extra_cheese
167+
+ExtraCheeseDecorator(PizzaBuilder, int)
168+
+PizzaBuilder apply()
169+
}
170+
171+
%% Seasonal Promotions Decorator
172+
class K2434232_SeasonalPromotionsDecorator {
173+
-Dict holiday_seasons
174+
+SeasonalPromotionsDecorator(Union[PizzaBuilder, PizzaCustomizationHandler, str, Pizza])
175+
+bool is_holiday_season()
176+
+PizzaBuilder apply(Fore, Style)
177+
}
178+
179+
%% Get Pizza For Free Decorator
180+
class K2434232_GetPizzaForFreeDecorator {
181+
-int factor_of_free
182+
+GetPizzaForFreeDecorator(Union[PizzaBuilder, PizzaCustomizationHandler, PizzaDecorator], int)
183+
+PizzaBuilder apply()
184+
}
185+
186+
class K2434232_SeasonalToppingsDecorator {
187+
+Pizza apply()
188+
}
189+
190+
class K2434232_Price {
191+
-float base_amount
192+
-float tax
193+
-float discount
194+
+float calculate_total()
195+
+void apply_discount(float)
196+
+float get_price()
197+
+void price_calculator_for_cheeses(List[str])
198+
+void price_calculator_for_crusts(List[str])
199+
+void price_calculator_for_sauces(List[str])
200+
+void price_calculator_for_toppings(List[str])
201+
}
202+
203+
%% Core Composition Relationships with Orthogonal Lines
204+
Order o-- "1" Pizza
205+
Order o-- "1" User
206+
Order o-- "1" OrderState
207+
Order o-- "1" Payment
208+
Order o-- "*" OrderObserver
209+
Payment o-- "1" PaymentStrategy
210+
PizzaBuilder o-- "1" PizzaDecorator
211+
PizzaBuilder o-- "1" Pizza
212+
Pizza o-- "1" Price
213+
214+
%% State Pattern Inheritance (90-degree connections)
215+
OrderState <|-- PlacedState : extends
216+
OrderState <|-- PreparingState : extends
217+
OrderState <|-- BakingState : extends
218+
OrderState <|-- DeliveredState : extends
219+
220+
%% Observer Pattern Implementation (Orthogonal)
221+
OrderObserver <|.. CustomerNotifier : implements
222+
OrderObserver <|.. KitchenDisplay : implements
223+
224+
%% Strategy Pattern Implementation
225+
PaymentStrategy <|.. CreditCardStrategy : implements
226+
PaymentStrategy <|.. PayPalStrategy : implements
227+
PaymentStrategy <|.. DigitalWalletStrategy : implements
228+
229+
%% Decorator Pattern Extensions
230+
PizzaDecorator <|-- ExtraCheeseDecorator : extends
231+
PizzaDecorator <|-- SeasonalPromotionsDecorator : extends
232+
PizzaDecorator <|-- GetPizzaForFreeDecorator : extends
233+
PizzaDecorator <|-- SeasonalToppingsDecorator : extends
234+
235+
%% Layout Direction
236+
direction TB
359 KB
Loading

docs/diagrams/classDiagram/classDiagram.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)