ZahirJS commited on
Commit
5ca5e5c
·
verified ·
1 Parent(s): cf262b9

Update class_diagram_generator.py

Browse files
Files changed (1) hide show
  1. class_diagram_generator.py +238 -88
class_diagram_generator.py CHANGED
@@ -15,164 +15,314 @@ def generate_class_diagram(json_input: str, output_format: str) -> str:
15
  {
16
  "classes": [
17
  {
18
- "name": "Vehicle",
19
- "type": "abstract",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  "attributes": [
21
- {"name": "id", "type": "String", "visibility": "-"},
22
- {"name": "brand", "type": "String", "visibility": "#"},
23
- {"name": "model", "type": "String", "visibility": "#"},
24
- {"name": "year", "type": "int", "visibility": "#"},
25
- {"name": "price", "type": "double", "visibility": "+"},
26
- {"name": "vehicleCount", "type": "int", "visibility": "+", "static": true}
27
  ],
28
  "methods": [
29
- {"name": "Vehicle", "parameters": [{"name": "brand", "type": "String"}, {"name": "model", "type": "String"}], "return_type": "Vehicle", "visibility": "+"},
30
- {"name": "startEngine", "return_type": "void", "visibility": "+", "abstract": true},
31
- {"name": "stopEngine", "return_type": "void", "visibility": "+"},
32
- {"name": "getPrice", "return_type": "double", "visibility": "+"},
33
- {"name": "setPrice", "parameters": [{"name": "price", "type": "double"}], "return_type": "void", "visibility": "+"},
34
- {"name": "getTotalVehicles", "return_type": "int", "visibility": "+", "static": true}
35
  ]
36
  },
37
  {
38
- "name": "Car",
39
  "type": "class",
40
  "attributes": [
41
- {"name": "doors", "type": "int", "visibility": "-"},
42
- {"name": "transmission", "type": "TransmissionType", "visibility": "-"},
43
- {"name": "fuelType", "type": "FuelType", "visibility": "-"}
 
44
  ],
45
  "methods": [
46
- {"name": "Car", "parameters": [{"name": "brand", "type": "String"}, {"name": "model", "type": "String"}, {"name": "doors", "type": "int"}], "return_type": "Car", "visibility": "+"},
47
- {"name": "startEngine", "return_type": "void", "visibility": "+"},
48
- {"name": "openTrunk", "return_type": "void", "visibility": "+"},
49
- {"name": "getDoors", "return_type": "int", "visibility": "+"},
50
- {"name": "setTransmission", "parameters": [{"name": "transmission", "type": "TransmissionType"}], "return_type": "void", "visibility": "+"}
51
  ]
52
  },
53
  {
54
- "name": "Motorcycle",
55
  "type": "class",
56
  "attributes": [
57
- {"name": "engineSize", "type": "int", "visibility": "-"},
58
- {"name": "hasWindshield", "type": "boolean", "visibility": "-"}
 
 
59
  ],
60
  "methods": [
61
- {"name": "Motorcycle", "parameters": [{"name": "brand", "type": "String"}, {"name": "model", "type": "String"}], "return_type": "Motorcycle", "visibility": "+"},
62
- {"name": "startEngine", "return_type": "void", "visibility": "+"},
63
- {"name": "wheelie", "return_type": "void", "visibility": "+"},
64
- {"name": "getEngineSize", "return_type": "int", "visibility": "+"}
65
  ]
66
  },
67
  {
68
- "name": "Engine",
69
  "type": "class",
70
  "attributes": [
71
- {"name": "horsepower", "type": "int", "visibility": "-"},
72
- {"name": "cylinders", "type": "int", "visibility": "-"},
73
- {"name": "fuelType", "type": "FuelType", "visibility": "-"}
 
 
74
  ],
75
  "methods": [
76
- {"name": "Engine", "parameters": [{"name": "horsepower", "type": "int"}, {"name": "cylinders", "type": "int"}], "return_type": "Engine", "visibility": "+"},
77
- {"name": "start", "return_type": "boolean", "visibility": "+"},
78
- {"name": "stop", "return_type": "void", "visibility": "+"},
79
- {"name": "getHorsepower", "return_type": "int", "visibility": "+"}
80
  ]
81
  },
82
  {
83
- "name": "TransmissionType",
84
- "type": "enum",
85
  "attributes": [
86
- {"name": "MANUAL", "type": "TransmissionType", "visibility": "+", "static": true},
87
- {"name": "AUTOMATIC", "type": "TransmissionType", "visibility": "+", "static": true},
88
- {"name": "CVT", "type": "TransmissionType", "visibility": "+", "static": true}
 
89
  ],
90
- "methods": []
 
 
 
91
  },
92
  {
93
- "name": "FuelType",
94
- "type": "enum",
95
  "attributes": [
96
- {"name": "GASOLINE", "type": "FuelType", "visibility": "+", "static": true},
97
- {"name": "DIESEL", "type": "FuelType", "visibility": "+", "static": true},
98
- {"name": "ELECTRIC", "type": "FuelType", "visibility": "+", "static": true},
99
- {"name": "HYBRID", "type": "FuelType", "visibility": "+", "static": true}
 
100
  ],
101
- "methods": []
 
 
 
102
  },
103
  {
104
- "name": "VehicleService",
105
- "type": "interface",
106
- "attributes": [],
 
 
 
 
 
 
107
  "methods": [
108
- {"name": "maintenance", "parameters": [{"name": "vehicle", "type": "Vehicle"}], "return_type": "void", "visibility": "+", "abstract": true},
109
- {"name": "repair", "parameters": [{"name": "vehicle", "type": "Vehicle"}, {"name": "issue", "type": "String"}], "return_type": "boolean", "visibility": "+", "abstract": true},
110
- {"name": "inspectVehicle", "parameters": [{"name": "vehicle", "type": "Vehicle"}], "return_type": "InspectionReport", "visibility": "+", "abstract": true}
111
  ]
112
  },
113
  {
114
- "name": "GarageService",
115
  "type": "class",
116
  "attributes": [
117
- {"name": "garageName", "type": "String", "visibility": "-"},
118
- {"name": "location", "type": "String", "visibility": "-"}
 
 
 
119
  ],
120
  "methods": [
121
- {"name": "GarageService", "parameters": [{"name": "name", "type": "String"}], "return_type": "GarageService", "visibility": "+"},
122
- {"name": "maintenance", "parameters": [{"name": "vehicle", "type": "Vehicle"}], "return_type": "void", "visibility": "+"},
123
- {"name": "repair", "parameters": [{"name": "vehicle", "type": "Vehicle"}, {"name": "issue", "type": "String"}], "return_type": "boolean", "visibility": "+"},
124
- {"name": "inspectVehicle", "parameters": [{"name": "vehicle", "type": "Vehicle"}], "return_type": "InspectionReport", "visibility": "+"}
125
  ]
126
  }
127
  ],
128
  "relationships": [
129
  {
130
- "from": "Car",
131
- "to": "Vehicle",
132
- "type": "inheritance"
 
 
133
  },
134
  {
135
- "from": "Motorcycle",
136
- "to": "Vehicle",
137
- "type": "inheritance"
 
 
138
  },
139
  {
140
- "from": "Car",
141
- "to": "Engine",
 
 
 
 
 
 
 
142
  "type": "composition",
143
  "multiplicity_from": "1",
144
- "multiplicity_to": "1"
 
 
 
 
 
 
 
145
  },
146
  {
147
- "from": "Motorcycle",
148
- "to": "Engine",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  "type": "composition",
150
  "multiplicity_from": "1",
151
- "multiplicity_to": "1"
152
  },
153
  {
154
- "from": "Car",
155
- "to": "TransmissionType",
156
  "type": "association",
157
  "multiplicity_from": "1",
158
- "multiplicity_to": "1"
159
  },
160
  {
161
- "from": "Vehicle",
162
- "to": "FuelType",
163
  "type": "association",
164
  "multiplicity_from": "1",
165
- "multiplicity_to": "1"
166
  },
167
  {
168
- "from": "GarageService",
169
- "to": "VehicleService",
170
- "type": "realization"
 
 
 
 
 
 
 
 
 
171
  },
172
  {
173
- "from": "GarageService",
174
- "to": "Vehicle",
175
- "type": "dependency",
 
 
 
 
 
 
 
176
  "multiplicity_from": "1",
177
  "multiplicity_to": "*"
178
  }
 
15
  {
16
  "classes": [
17
  {
18
+ "name": "Student",
19
+ "type": "class",
20
+ "attributes": [
21
+ {"name": "studentId", "type": "String", "visibility": "-"},
22
+ {"name": "username", "type": "String", "visibility": "+"},
23
+ {"name": "email", "type": "String", "visibility": "+"},
24
+ {"name": "enrollmentDate", "type": "Date", "visibility": "+"},
25
+ {"name": "currentLevel", "type": "String", "visibility": "+"}
26
+ ],
27
+ "methods": [
28
+ {"name": "Student", "parameters": [{"name": "username", "type": "String"}, {"name": "email", "type": "String"}], "return_type": "Student", "visibility": "+"},
29
+ {"name": "enrollCourse", "parameters": [{"name": "courseId", "type": "String"}], "return_type": "boolean", "visibility": "+"},
30
+ {"name": "updateProgress", "parameters": [{"name": "lessonId", "type": "String"}], "return_type": "void", "visibility": "+"}
31
+ ]
32
+ },
33
+ {
34
+ "name": "CourseEnrollment",
35
+ "type": "class",
36
+ "attributes": [
37
+ {"name": "enrollmentId", "type": "String", "visibility": "-"},
38
+ {"name": "studentId", "type": "String", "visibility": "+"},
39
+ {"name": "courseId", "type": "String", "visibility": "+"},
40
+ {"name": "enrollmentDate", "type": "Date", "visibility": "+"},
41
+ {"name": "progress", "type": "double", "visibility": "+"}
42
+ ],
43
+ "methods": [
44
+ {"name": "CourseEnrollment", "parameters": [{"name": "studentId", "type": "String"}, {"name": "courseId", "type": "String"}], "return_type": "CourseEnrollment", "visibility": "+"},
45
+ {"name": "calculateProgress", "return_type": "double", "visibility": "+"}
46
+ ]
47
+ },
48
+ {
49
+ "name": "Course",
50
+ "type": "class",
51
+ "attributes": [
52
+ {"name": "courseId", "type": "String", "visibility": "-"},
53
+ {"name": "title", "type": "String", "visibility": "+"},
54
+ {"name": "description", "type": "String", "visibility": "+"},
55
+ {"name": "difficulty", "type": "String", "visibility": "+"},
56
+ {"name": "duration", "type": "int", "visibility": "+"}
57
+ ],
58
+ "methods": [
59
+ {"name": "Course", "parameters": [{"name": "title", "type": "String"}], "return_type": "Course", "visibility": "+"},
60
+ {"name": "addLesson", "parameters": [{"name": "lesson", "type": "Lesson"}], "return_type": "void", "visibility": "+"}
61
+ ]
62
+ },
63
+ {
64
+ "name": "Instructor",
65
+ "type": "class",
66
+ "attributes": [
67
+ {"name": "instructorId", "type": "String", "visibility": "-"},
68
+ {"name": "name", "type": "String", "visibility": "+"},
69
+ {"name": "expertise", "type": "String", "visibility": "+"},
70
+ {"name": "rating", "type": "double", "visibility": "+"}
71
+ ],
72
+ "methods": [
73
+ {"name": "Instructor", "parameters": [{"name": "name", "type": "String"}, {"name": "expertise", "type": "String"}], "return_type": "Instructor", "visibility": "+"},
74
+ {"name": "createCourse", "parameters": [{"name": "title", "type": "String"}], "return_type": "Course", "visibility": "+"}
75
+ ]
76
+ },
77
+ {
78
+ "name": "Lesson",
79
+ "type": "class",
80
+ "attributes": [
81
+ {"name": "lessonId", "type": "String", "visibility": "-"},
82
+ {"name": "title", "type": "String", "visibility": "+"},
83
+ {"name": "courseId", "type": "String", "visibility": "+"},
84
+ {"name": "duration", "type": "int", "visibility": "+"},
85
+ {"name": "order", "type": "int", "visibility": "+"}
86
+ ],
87
+ "methods": [
88
+ {"name": "Lesson", "parameters": [{"name": "title", "type": "String"}], "return_type": "Lesson", "visibility": "+"},
89
+ {"name": "markCompleted", "parameters": [{"name": "studentId", "type": "String"}], "return_type": "void", "visibility": "+"}
90
+ ]
91
+ },
92
+ {
93
+ "name": "VideoContent",
94
+ "type": "class",
95
+ "attributes": [
96
+ {"name": "videoId", "type": "String", "visibility": "-"},
97
+ {"name": "lessonId", "type": "String", "visibility": "+"},
98
+ {"name": "videoUrl", "type": "String", "visibility": "+"},
99
+ {"name": "duration", "type": "int", "visibility": "+"}
100
+ ],
101
+ "methods": [
102
+ {"name": "VideoContent", "parameters": [{"name": "lessonId", "type": "String"}, {"name": "videoUrl", "type": "String"}], "return_type": "VideoContent", "visibility": "+"},
103
+ {"name": "play", "return_type": "void", "visibility": "+"}
104
+ ]
105
+ },
106
+ {
107
+ "name": "WatchProgress",
108
+ "type": "class",
109
  "attributes": [
110
+ {"name": "progressId", "type": "String", "visibility": "-"},
111
+ {"name": "studentId", "type": "String", "visibility": "+"},
112
+ {"name": "videoId", "type": "String", "visibility": "+"},
113
+ {"name": "watchedMinutes", "type": "int", "visibility": "+"}
 
 
114
  ],
115
  "methods": [
116
+ {"name": "WatchProgress", "parameters": [{"name": "studentId", "type": "String"}, {"name": "videoId", "type": "String"}], "return_type": "WatchProgress", "visibility": "+"},
117
+ {"name": "updateProgress", "parameters": [{"name": "minutes", "type": "int"}], "return_type": "void", "visibility": "+"}
 
 
 
 
118
  ]
119
  },
120
  {
121
+ "name": "Quiz",
122
  "type": "class",
123
  "attributes": [
124
+ {"name": "quizId", "type": "String", "visibility": "-"},
125
+ {"name": "lessonId", "type": "String", "visibility": "+"},
126
+ {"name": "title", "type": "String", "visibility": "+"},
127
+ {"name": "passingScore", "type": "int", "visibility": "+"}
128
  ],
129
  "methods": [
130
+ {"name": "Quiz", "parameters": [{"name": "title", "type": "String"}], "return_type": "Quiz", "visibility": "+"},
131
+ {"name": "addQuestion", "parameters": [{"name": "question", "type": "Question"}], "return_type": "void", "visibility": "+"}
 
 
 
132
  ]
133
  },
134
  {
135
+ "name": "Question",
136
  "type": "class",
137
  "attributes": [
138
+ {"name": "questionId", "type": "String", "visibility": "-"},
139
+ {"name": "quizId", "type": "String", "visibility": "+"},
140
+ {"name": "questionText", "type": "String", "visibility": "+"},
141
+ {"name": "questionType", "type": "String", "visibility": "+"}
142
  ],
143
  "methods": [
144
+ {"name": "Question", "parameters": [{"name": "questionText", "type": "String"}], "return_type": "Question", "visibility": "+"},
145
+ {"name": "addOption", "parameters": [{"name": "option", "type": "String"}], "return_type": "void", "visibility": "+"}
 
 
146
  ]
147
  },
148
  {
149
+ "name": "QuizAttempt",
150
  "type": "class",
151
  "attributes": [
152
+ {"name": "attemptId", "type": "String", "visibility": "-"},
153
+ {"name": "studentId", "type": "String", "visibility": "+"},
154
+ {"name": "quizId", "type": "String", "visibility": "+"},
155
+ {"name": "score", "type": "int", "visibility": "+"},
156
+ {"name": "attemptDate", "type": "Date", "visibility": "+"}
157
  ],
158
  "methods": [
159
+ {"name": "QuizAttempt", "parameters": [{"name": "studentId", "type": "String"}, {"name": "quizId", "type": "String"}], "return_type": "QuizAttempt", "visibility": "+"},
160
+ {"name": "submitAnswer", "parameters": [{"name": "questionId", "type": "String"}, {"name": "answer", "type": "String"}], "return_type": "void", "visibility": "+"}
 
 
161
  ]
162
  },
163
  {
164
+ "name": "Discussion",
165
+ "type": "class",
166
  "attributes": [
167
+ {"name": "discussionId", "type": "String", "visibility": "-"},
168
+ {"name": "courseId", "type": "String", "visibility": "+"},
169
+ {"name": "title", "type": "String", "visibility": "+"},
170
+ {"name": "createdDate", "type": "Date", "visibility": "+"}
171
  ],
172
+ "methods": [
173
+ {"name": "Discussion", "parameters": [{"name": "title", "type": "String"}], "return_type": "Discussion", "visibility": "+"},
174
+ {"name": "addPost", "parameters": [{"name": "studentId", "type": "String"}, {"name": "message", "type": "String"}], "return_type": "void", "visibility": "+"}
175
+ ]
176
  },
177
  {
178
+ "name": "Post",
179
+ "type": "class",
180
  "attributes": [
181
+ {"name": "postId", "type": "String", "visibility": "-"},
182
+ {"name": "discussionId", "type": "String", "visibility": "+"},
183
+ {"name": "authorId", "type": "String", "visibility": "+"},
184
+ {"name": "content", "type": "String", "visibility": "+"},
185
+ {"name": "postDate", "type": "Date", "visibility": "+"}
186
  ],
187
+ "methods": [
188
+ {"name": "Post", "parameters": [{"name": "authorId", "type": "String"}, {"name": "content", "type": "String"}], "return_type": "Post", "visibility": "+"},
189
+ {"name": "reply", "parameters": [{"name": "replyContent", "type": "String"}], "return_type": "void", "visibility": "+"}
190
+ ]
191
  },
192
  {
193
+ "name": "Certificate",
194
+ "type": "class",
195
+ "attributes": [
196
+ {"name": "certificateId", "type": "String", "visibility": "-"},
197
+ {"name": "studentId", "type": "String", "visibility": "+"},
198
+ {"name": "courseId", "type": "String", "visibility": "+"},
199
+ {"name": "issueDate", "type": "Date", "visibility": "+"},
200
+ {"name": "grade", "type": "String", "visibility": "+"}
201
+ ],
202
  "methods": [
203
+ {"name": "Certificate", "parameters": [{"name": "studentId", "type": "String"}, {"name": "courseId", "type": "String"}], "return_type": "Certificate", "visibility": "+"},
204
+ {"name": "generatePDF", "return_type": "String", "visibility": "+"}
 
205
  ]
206
  },
207
  {
208
+ "name": "Payment",
209
  "type": "class",
210
  "attributes": [
211
+ {"name": "paymentId", "type": "String", "visibility": "-"},
212
+ {"name": "studentId", "type": "String", "visibility": "+"},
213
+ {"name": "courseId", "type": "String", "visibility": "+"},
214
+ {"name": "amount", "type": "double", "visibility": "+"},
215
+ {"name": "paymentDate", "type": "Date", "visibility": "+"}
216
  ],
217
  "methods": [
218
+ {"name": "Payment", "parameters": [{"name": "studentId", "type": "String"}, {"name": "amount", "type": "double"}], "return_type": "Payment", "visibility": "+"},
219
+ {"name": "processPayment", "return_type": "boolean", "visibility": "+"}
 
 
220
  ]
221
  }
222
  ],
223
  "relationships": [
224
  {
225
+ "from": "Student",
226
+ "to": "CourseEnrollment",
227
+ "type": "association",
228
+ "multiplicity_from": "1",
229
+ "multiplicity_to": "*"
230
  },
231
  {
232
+ "from": "CourseEnrollment",
233
+ "to": "Course",
234
+ "type": "association",
235
+ "multiplicity_from": "*",
236
+ "multiplicity_to": "1"
237
  },
238
  {
239
+ "from": "Instructor",
240
+ "to": "Course",
241
+ "type": "association",
242
+ "multiplicity_from": "1",
243
+ "multiplicity_to": "*"
244
+ },
245
+ {
246
+ "from": "Course",
247
+ "to": "Lesson",
248
  "type": "composition",
249
  "multiplicity_from": "1",
250
+ "multiplicity_to": "*"
251
+ },
252
+ {
253
+ "from": "Lesson",
254
+ "to": "VideoContent",
255
+ "type": "association",
256
+ "multiplicity_from": "1",
257
+ "multiplicity_to": "*"
258
  },
259
  {
260
+ "from": "Student",
261
+ "to": "WatchProgress",
262
+ "type": "association",
263
+ "multiplicity_from": "1",
264
+ "multiplicity_to": "*"
265
+ },
266
+ {
267
+ "from": "VideoContent",
268
+ "to": "WatchProgress",
269
+ "type": "association",
270
+ "multiplicity_from": "1",
271
+ "multiplicity_to": "*"
272
+ },
273
+ {
274
+ "from": "Lesson",
275
+ "to": "Quiz",
276
+ "type": "association",
277
+ "multiplicity_from": "1",
278
+ "multiplicity_to": "*"
279
+ },
280
+ {
281
+ "from": "Quiz",
282
+ "to": "Question",
283
  "type": "composition",
284
  "multiplicity_from": "1",
285
+ "multiplicity_to": "*"
286
  },
287
  {
288
+ "from": "Student",
289
+ "to": "QuizAttempt",
290
  "type": "association",
291
  "multiplicity_from": "1",
292
+ "multiplicity_to": "*"
293
  },
294
  {
295
+ "from": "Quiz",
296
+ "to": "QuizAttempt",
297
  "type": "association",
298
  "multiplicity_from": "1",
299
+ "multiplicity_to": "*"
300
  },
301
  {
302
+ "from": "Course",
303
+ "to": "Discussion",
304
+ "type": "aggregation",
305
+ "multiplicity_from": "1",
306
+ "multiplicity_to": "*"
307
+ },
308
+ {
309
+ "from": "Discussion",
310
+ "to": "Post",
311
+ "type": "composition",
312
+ "multiplicity_from": "1",
313
+ "multiplicity_to": "*"
314
  },
315
  {
316
+ "from": "Student",
317
+ "to": "Certificate",
318
+ "type": "association",
319
+ "multiplicity_from": "1",
320
+ "multiplicity_to": "*"
321
+ },
322
+ {
323
+ "from": "Student",
324
+ "to": "Payment",
325
+ "type": "association",
326
  "multiplicity_from": "1",
327
  "multiplicity_to": "*"
328
  }