-
Notifications
You must be signed in to change notification settings - Fork 0
/
school_system.py
703 lines (529 loc) · 28.9 KB
/
school_system.py
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
# -----------------------> the program need some fix <-------------------------
# ----- 1. you can/need to remove [clear()] from display_functions() below
# ----- because they clear the screen before "i as a user" can't read the output
# ------------------------------------------------------------------------------
# this is to me ;)
#
# 2024-06-04
#
import os
import OOP_2
import OOP_3
#from colors import Colors
class Colors:
green=''
end=''
blue=''
red=''
yellow=''
def clear():
pass
def welcome_mass(): # print : welcome to the SMS -> (school management system)
print(f"""\n{Colors.green}
********************
* Welcome to SMS *
********************{Colors.end}\n""")
def display_home_menu(): # show a list: 1.teacher. 2.student. 3.info of SMS. 0.exit
print(f"""
{Colors.green}*** home menu ***{Colors.end}
1. Teacher.
2. Student.
3. What is SMS.
0. Exit.""")
user_in = input("Please enter a number: ")
return user_in
# show a list: 1.teacher({t1.get_name()}). 2.teacher(2). 0.exit
def display_teacher_menu():
# clear()
print(f"""
{Colors.blue}*** Teachers menu ***{Colors.end}
1. {OOP_3.t1.get_name()}.
2. {OOP_3.t2.get_name()}.
0. Exit.""")
user_in = input("Please enter a number: ")
return user_in
def display_teacher_submenu(): # show a list: 1.set methods. 2.get methods. 0.exit
# clear()
print(f"""
{Colors.green}*** Teacher sub-menu ***{Colors.end}
1. Set methods.
2. Get methods.
3. Teacher information.
0. Exit.""")
user_in = input("Please enter a number: ")
return user_in
def display_teacher_set_menu(): # show a list: 1.set name. 2.set salary. etc. 0.exit
# clear()
print(f"""
{Colors.blue}*** Teacher set menu ***{Colors.end}
1. Set name.
2. Set born year.
3. Set salary.
4. Set email.
5. Set address.
6. Set phone number.
0. Exit.""")
user_in = input("Please enter a number: ")
return user_in
def display_teacher_get_menu(): # show a list: 1.get name. 2.get salary. etc. 0.exit
# clear()
print(f"""
{Colors.green}*** Teacher get menu ***{Colors.end}
1. Get name.
2. Get born year.
3. Get salary.
4. Get email.
5. Get address.
6. Get phone number.
7. Get age.
8. Get teacher information.
9. Get ID
0. Exit.""")
user_in = input("Please enter a number: ")
return user_in
def display_student_menu(): # show a list: 1.student(1). 2.student(2). 0.exit
# clear()
print(f"""
{Colors.blue}*** Students menu ***{Colors.end}
1. {OOP_2.s1.get_name()}.
2. {OOP_2.s2.get_name()}.
0. Exit.""")
user_in = input("Please enter a number: ")
return user_in
def display_student_submenu(): # show a list: 1.set methods. 2.get methods. 0.exit
# clear()
print(f"""
{Colors.green}*** Student sub-menu ***{Colors.end}
1. Set methods.
2. Get methods.
3. Student information.
0. Exit.""")
user_in = input("Please enter a number: ")
return user_in
def display_student_set_menu(): # show a list: 1.set name. 2.set salary. etc. 0.exit
# clear()
print(f"""
{Colors.blue}*** Students set menu ***{Colors.end}
1. Set name.
2. Set born year.
3. Set grade.
4. Set email.
5. Set address.
6. Set phone number.
0. Exit.""")
user_in = input("Please enter a number: ")
return user_in
def display_student_get_menu(): # show a list: 1.get name. 2.get salary. etc. 0.exit
# clear()
print(f"""
{Colors.green}*** Students get menu ***{Colors.end}
1. Get name.
2. Get born year.
3. Get grade.
4. Get email.
5. Get address.
6. Get phone number.
7. Get age.
8. Get student information.
9. Get ID
0. Exit.""")
user_in = input("Please enter a number: ")
return user_in
def display_info_menu(): # show: instructions of the system. display_home_menu()
print(f"""{Colors.blue}
*********************************
SMS -> School Management System,
this system let you set & get
almost everything, like info. of
teachers and students (for now).
*********************************
{Colors.end}""")
def display_exit_mass(): # show: Exit with the red color
print(f"\n{Colors.red}Exit{Colors.end}")
def display_error_mass():
print(f"{Colors.yellow}error with inputs!{Colors.end}")
def main():
welcome_mass()
while True: # the main() loop <--
user_in = display_home_menu()
if user_in == "1": # <-- <-- 1. teacher <--
while True: # <-- <-- the loop of teacher <--
user_in = display_teacher_menu()
# <-- <-- 1. first object in teacher <--
if user_in == '1':
while True: # <-- <-- the loop of teacher object set/get-methods <--
user_in = display_teacher_submenu()
# <-- <-- 1. sets in teacher object <--
if user_in == '1':
while True: # <-- <-- the loop of teacher object set menu <--
user_in = display_teacher_set_menu()
# <-- <-- set name to teacher object <--
if user_in == '1':
user_data = input("Enter a name: ")
OOP_3.t1.set_name(user_data)
# <-- <-- set born year to teacher object <--
elif user_in == '2':
user_data = input("Enter a born year: ")
if user_data.isdigit():
OOP_3.t1.set_born_year(user_data)
else:
display_error_mass()
# <-- <-- set salary to teacher object <--
elif user_in == '3':
user_data = input("Enter a salary: ")
if user_data.isdigit():
OOP_3.t1.set_salary(user_data)
else:
display_error_mass()
# <-- <-- set email to teacher object <--
elif user_in == '4':
user_data = input("Enter a email: ")
OOP_3.t1.set_email(user_data)
# <-- <-- set address to teacher object <--
elif user_in == '5':
user_data = input("Enter a address: ")
OOP_3.t1.set_address(user_data)
# <-- <-- set phone No. to teacher object <--
elif user_in == '6':
user_data = input("Enter a phone number: ")
OOP_3.t1.set_phone_number(user_data)
# <-- <-- exit from set menu <--
elif user_in == '0':
display_exit_mass()
break
else:
display_error_mass() # <-- <-- ?. error in teacher object <--
# <-- <-- 2. gets in teacher object <--
elif user_in == '2':
while True: # <-- <-- the loop of teacher object get menu <--
user_in = display_teacher_get_menu()
# <-- <-- get name of teacher object <--
if user_in == '1':
print(f"Name: {OOP_3.t1.get_name()}.")
# <-- <-- get born year of teacher object <--
elif user_in == '2':
print(f"Born year: {OOP_3.t1.get_born_year()}.")
# <-- <-- get salary of teacher object <--
elif user_in == '3':
print(f"Salary: {OOP_3.t1.get_salary()}.")
# <-- <-- get email of teacher object <--
elif user_in == '4':
print(f"Email: {OOP_3.t1.get_email()}.")
# <-- <-- get address of teacher object <--
elif user_in == '5':
print(f"Address: {OOP_3.t1.get_address()}.")
# <-- <-- get phone No. of teacher object <--
elif user_in == '6':
print(f"Phone no: {OOP_3.t1.get_phone_number()}.")
# <-- <-- get age of teacher object <--
elif user_in == '7':
print(f"Age: {OOP_3.t1.get_age()}.")
# <-- <-- get teacher info of teacher object <--
elif user_in == '8':
print(OOP_3.t1)
# <-- <-- get id of teacher object <--
elif user_in == '9':
print(f"Teacher ID: {OOP_3.Teacher.teacher_id}.")
# <-- <-- exit from get menu <--
elif user_in == '0':
display_exit_mass()
break
else:
display_error_mass() # <-- <-- ?. error in teacher object <--
# <-- <-- 3. display teacher object info <--
elif user_in == '3':
print(OOP_3.t1)
# <-- <-- 0. exit from teacher object <--
elif user_in == '0':
display_exit_mass()
break
else: # <-- <-- ?. error in teacher object <--
display_error_mass()
# <-- <-- 2. 2ed object in teacher <--
elif user_in == '2':
while True: # <-- <-- the loop of teacher object set/get-methods <--
user_in = display_teacher_submenu()
# <-- <-- 1. sets in teacher object <--
if user_in == '1':
while True: # <-- <-- the loop of teacher object set menu <--
user_in = display_teacher_set_menu()
# <-- <-- set name to teacher object <--
if user_in == '1':
user_data = input("Enter a name: ")
OOP_3.t2.set_name(user_data)
# <-- <-- set born year to teacher object <--
elif user_in == '2':
user_data = input("Enter a born year: ")
if user_data.isdigit():
OOP_3.t2.set_born_year(user_data)
else:
display_error_mass()
# <-- <-- set salary to teacher object <--
elif user_in == '3':
user_data = input("Enter a salary: ")
if user_data.isdigit():
OOP_3.t2.set_salary(user_data)
else:
display_error_mass()
# <-- <-- set email to teacher object <--
elif user_in == '4':
user_data = input("Enter a email: ")
OOP_3.t2.set_email(user_data)
# <-- <-- set address to teacher object <--
elif user_in == '5':
user_data = input("Enter a address: ")
OOP_3.t2.set_address(user_data)
# <-- <-- set phone No. to teacher object <--
elif user_in == '6':
user_data = input("Enter a phone number: ")
OOP_3.t2.set_phone_number(user_data)
# <-- <-- exit from set menu <--
elif user_in == '0':
display_exit_mass()
break
else:
display_error_mass() # <-- <-- ?. error in teacher object <--
# <-- <-- 2. gets in teacher object <--
elif user_in == '2':
while True: # <-- <-- the loop of teacher object get menu <--
user_in = display_teacher_get_menu()
# <-- <-- get name of teacher object <--
if user_in == '1':
print(f"Name: {OOP_3.t2.get_name()}.")
# <-- <-- get born year of teacher object <--
elif user_in == '2':
print(f"Born year: {OOP_3.t2.get_born_year()}.")
# <-- <-- get salary of teacher object <--
elif user_in == '3':
print(f"Salary: {OOP_3.t2.get_salary()}.")
# <-- <-- get email of teacher object <--
elif user_in == '4':
print(f"Email: {OOP_3.t2.get_email()}.")
# <-- <-- get address of teacher object <--
elif user_in == '5':
print(f"Address: {OOP_3.t2.get_address()}.")
# <-- <-- get phone No. of teacher object <--
elif user_in == '6':
print(f"Phone no: {OOP_3.t2.get_phone_number()}.")
# <-- <-- get age of teacher object <--
elif user_in == '7':
print(f"Age: {OOP_3.t2.get_age()}.")
# <-- <-- get teacher info of teacher object <--
elif user_in == '8':
print(OOP_3.t2)
# <-- <-- get id of teacher object <--
elif user_in == '9':
print(f"Teacher ID: {OOP_3.Teacher.teacher_id}.")
# <-- <-- exit from get menu <--
elif user_in == '0':
display_exit_mass()
break
else:
display_error_mass() # <-- <-- ?. error in teacher object <--
# <-- <-- 3. display teacher object info <--
elif user_in == '3':
print(OOP_3.t2)
# <-- <-- 0. exit from teacher object <--
elif user_in == '0':
display_exit_mass()
break
else: # <-- <-- ?. error in teacher object <--
display_error_mass()
elif user_in == '0': # <-- <-- 0. exit from teacher <--
display_exit_mass()
break
else:
display_error_mass() # <-- <-- ?. error in teacher <--
# user_in = input("Do you want to ")
elif user_in == "2": # <-- <-- 2. student <--
while True: # <-- <-- the loop of student <--
user_in = display_student_menu()
# <-- <-- 1. first object in student <--
if user_in == '1':
while True: # <-- <-- the loop of student 1st object set/get menu <--
user_in = display_student_submenu()
# <-- <-- 1. sets in 1st student object <--
if user_in == '1':
while True: # <-- <-- the loop of 1st student object set menu <--
user_in = display_student_set_menu()
# <-- <-- set name to 1st student object <--
if user_in == '1':
user_data = input("Enter a name: ")
OOP_2.s1.set_name(user_data)
# <-- <-- set born year to 1st student object <--
elif user_in == '2':
user_data = input("Enter a born year: ")
if user_data.isdigit():
OOP_2.s1.set_born_year(user_data)
else:
display_error_mass()
# <-- <-- set grade to 1st student object <--
elif user_in == '3':
user_data = input("Enter a grade: ")
OOP_2.s1.set_grade(user_data)
# <-- <-- set email to 1st student object <--
elif user_in == '4':
user_data = input("Enter a email: ")
OOP_2.s1.set_email(user_data)
# <-- <-- set address to 1st student object <--
elif user_in == '5':
user_data = input("Enter a address: ")
OOP_2.s1.set_address(user_data)
# <-- <-- set phone no. to 1st student object <--
elif user_in == '6':
user_data = input("Enter a phone no: ")
OOP_2.s1.set_phone_number(user_data)
# <-- <-- exit from 1st student object set menu <--
elif user_in == '0':
display_exit_mass()
break
else:
display_error_mass() # <-- <-- error in student object set menu <--
# <-- <-- 2. gets in 1st student object <--
elif user_in == '2':
while True: # <-- <-- the loop of 1st student object get menu <--
user_in = display_student_get_menu()
# <-- <-- get name of 1st student object <--
if user_in == '1':
print(f"Name: {OOP_2.s1.get_name()}.")
# <-- <-- get born year of 1st student object <--
elif user_in == '2':
print(f"Born year: {OOP_2.s1.get_born_year()}.")
# <-- <-- get grade of 1st student object <--
elif user_in == '3':
print(f"Grade: {OOP_2.s1.get_grade()}.")
# <-- <-- get email of 1st student object <--
elif user_in == '4':
print(f"Email: {OOP_2.s1.get_email()}.")
# <-- <-- get address of 1st student object <--
elif user_in == '5':
print(f"Address: {OOP_2.s1.get_address()}.")
# <-- <-- get phone no. of 1st student object <--
elif user_in == '6':
print(f"Phone no: {OOP_2.s1.get_phone_number()}.")
# <-- <-- get age of 1st student object <--
elif user_in == '7':
print(f"Age: {OOP_2.s1.get_age()}.")
# <-- <-- get info. of 1st student object <--
elif user_in == '8':
print(f"Student info: {OOP_2.s1.get_student_info()}.")
# <-- <-- get id of 1st student object <--
elif user_in == '9':
print(f"Student ID: {OOP_2.Student.student_id}.")
# <-- <-- exit from 1st student object get menu <--
elif user_in == '0':
display_exit_mass()
break
else:
display_error_mass() # <-- <-- error in 1st student object inputs <--
# <-- <-- 3. print info. of 1st student object <--
elif user_in == '3':
print(f"Student info: {OOP_2.s1.get_student_info()}.")
# <-- <-- 0. exit from 1st student object <--
elif user_in == '0':
display_exit_mass()
break
else:
display_error_mass() # <-- <-- ?. error in 1st student object <--
# <-- <-- 2. 2ed object in student <--
elif user_in == '2':
while True: # <-- <-- the loop of student 2ed object set/get menu <--
user_in = display_student_submenu()
# <-- <-- 1. sets in 2ed student object <--
if user_in == '1':
while True: # <-- <-- the loop of 2ed student object set menu <--
user_in = display_student_set_menu()
# <-- <-- set name to student object <--
if user_in == '1':
user_data = input("Enter a name: ")
OOP_2.s2.set_name(user_data)
# <-- <-- set born year to student object <--
elif user_in == '2':
user_data = input("Enter a born year: ")
if user_data.isdigit():
OOP_2.s2.set_born_year(user_data)
else:
display_error_mass()
# <-- <-- set grade to student object <--
elif user_in == '3':
user_data = input("Enter a grade: ")
OOP_2.s2.set_grade(user_data)
# <-- <-- set email to student object <--
elif user_in == '4':
user_data = input("Enter a email: ")
OOP_2.s2.set_email(user_data)
# <-- <-- set address to student object <--
elif user_in == '5':
user_data = input("Enter a address: ")
OOP_2.s2.set_address(user_data)
# <-- <-- set phone no. to student object <--
elif user_in == '6':
user_data = input("Enter a phone no: ")
OOP_2.s2.set_phone_number(user_data)
# <-- <-- exit from student object set menu <--
elif user_in == '0':
display_exit_mass()
break
else:
display_error_mass() # <-- <-- error in student object set menu <--
# <-- <-- 2. gets in 2ed student object <--
elif user_in == '2':
while True: # <-- <-- the loop of 2ed student object get menu <--
user_in = display_student_get_menu()
# <-- <-- get name of 2ed student object <--
if user_in == '1':
print(f"Name: {OOP_2.s2.get_name()}.")
# <-- <-- get born year of 2ed student object <--
elif user_in == '2':
print(f"Born year: {OOP_2.s2.get_born_year()}.")
# <-- <-- get grade of 2ed student object <--
elif user_in == '3':
print(f"Grade: {OOP_2.s2.get_grade()}.")
# <-- <-- get email of 2ed student object <--
elif user_in == '4':
print(f"Email: {OOP_2.s2.get_email()}.")
# <-- <-- get address of 2ed student object <--
elif user_in == '5':
print(f"Address: {OOP_2.s2.get_address()}.")
# <-- <-- get phone no. of 2ed student object <--
elif user_in == '6':
print(f"Phone no: {OOP_2.s2.get_phone_number()}.")
# <-- <-- get age of 2ed student object <--
elif user_in == '7':
print(f"Age: {OOP_2.s2.get_age()}.")
# <-- <-- get info. of 2ed student object <--
elif user_in == '8':
print(f"Student info: {OOP_2.s2.get_student_info()}.")
# <-- <-- get id of 2ed student object <--
elif user_in == '9':
print(f"Student ID: {OOP_2.Student.student_id}.")
# <-- <-- exit from 2ed student object get menu <--
elif user_in == '0':
display_exit_mass()
break
else:
display_error_mass() # <-- <-- error in 2ed student object get menu inputs <--
# <-- <-- 3. print info. of 2ed student object <--
elif user_in == '3':
pass
# <-- <-- 0. exit from 2ed student object <--
elif user_in == '0':
display_exit_mass()
break
else:
display_error_mass() # <-- <-- ?. error in 2ed student object <--
elif user_in == '0': # <-- <-- 0. exit from student <--
display_exit_mass()
break
else:
display_error_mass()
# user_in = input("Do you want to ")
elif user_in == "3": # <-- <-- 3. what is SMS <--
display_info_menu()
elif user_in == "0": # <-- <-- 0. exit from main() loop <--
display_exit_mass()
break
else:
display_error_mass() # <-- <-- ?. error in main menu inputs <--
''' here we go '''
main()