学校管理系统代码未完成版
代码还没完成,遇到了瓶颈,请看的朋友留言给我,给点建议,完善一下
1 import datetime 2 3 class School(object): 4 '''总部学校类''' 5 def __init__(self,name,addr,website): 6 self.name = name 7 self.addr = addr 8 self.branches = {} #下属分校 9 self.website = website 10 self.balance = 0 11 print("创建了一个校区[%s],地址在[%s]" % (name,addr)) 12 13 def count_staff_num(self): 14 pass 15 16 def staff_enrollment(self,staff_obj): 17 pass 18 19 def count_total_revenue(self): 20 pass 21 22 class BranchSchool(School): 23 '''分校''' 24 def __init__(self,name,addr,headquarter_obj): 25 super().__init__(name,addr) 26 self.headquarter_obj = headquarter_obj 27 self.headquarter_obj.branches[name] =self 28 29 30 class Course(object): 31 '''课程''' 32 def __init__(self,name,price,outline): 33 self.name = name 34 self.price = price 35 self.outline = outline 36 print("创建了课程[%s],学费[%s]" % (name,price)) 37 38 class Class(object): 39 '''班级''' 40 def __init__(self,course_obj,semester,school_obj): 41 self.course_obj = course_obj 42 self.semester = semester 43 self.school_obj = school_obj 44 self.stu_list = [] 45 46 print("校区[%s]创建了班级[%s]-学期[%s].." %(school_obj.name,course_obj.name,semester)) 47 48 def stu_transfer(self,stu_obj,new_class_obj): 49 stu_obj.append(new_class_obj) 50 print("学员[%s]转学了.." % (stu_obj)) 51 52 def stu_dropout(self,stu_obj): 53 print("学员[%s]退学了..." % (stu_obj)) 54 55 class Staff(object): 56 '''员工类''' 57 def __init__(self,name,age,salary,dept,position,school_obj): 58 self.name = name 59 self.age = age 60 self.salary = salary 61 self.dept = dept 62 self.position = position 63 self.school_obj = school_obj 64 65 def punch_card(self): 66 print("员工[%s]正常上班打卡..." % (self.name)) 67 68 class Teacher(Staff): 69 def __init__(self,name,age,salary,dept,position,school_obj,course_obj): 70 super().__init__(self,name,age,salary,dept,position) 71 self.course_obj = course_obj #老师可以讲的课 72 def teach_class(self,class_obj,day): 73 print("老师[%s]正在班级[%s]上第[%s]天课" % (self.name,class_obj,day)) 74 75 class Student(object): 76 '''学员''' 77 def __init__(self,name,age,class_obj,balance): 78 self.name = name 79 self.age = age 80 self.class_obj = class_obj 81 self.balance = balance 82 83 #加入班级 84 self.class_obj.stu_list.append(self) 85 86 #交学费 87 def pay_tuition(self,class_obj,name): 88 89 self.balance -= class_obj.course_obj.price 90 self.class_obj.school_obj.balance += class_obj.course_obj.price 91 92 print("班级[%s]加入了新学员[%s],交费[%s]" %(class_obj,name,class_obj.course_obj.price)) 93 94 95 96 97 def punch_card(self): 98 print("%s:学员在班级[%s]上课了。。。" % (datetime.datetime.now(),self.class_obj)) 99 100 101 #创建校区 102 headquarter = School("老男孩IT教育集团","北京昌平沙河","oldboy.com") 103 sh1_school = School("张江校区","上海张江","oldboyedu.com") 104 sh2_school = School("虹桥校区","上海虹桥","oldboyedu.com") 105 luffy = School("深圳校区","深圳大学城","oldboyedu.com") 106 107 108 #创建课程 109 py_course = Course("Python开发","25800","None") 110 linux_course = Course("Linux运维","20000","None") 111 go_course = Course("GO开发","30000","None") 112 113 #创建班级 114 class1 = Class(py_course,24,headquarter) 115 class2 = Class(go_course,5,headquarter) 116 class3 = Class(py_course,12,sh1_school) 117 118 #创建员工、老师、员工 119 s1 = Staff("Alex",26,4000,"CEO","总经办",luffy) 120 s2 = Staff("Todd",45,60000,"CEO","总经办",headquarter) 121 s3 = Staff("明月",24,7000,"HR","HR",headquarter) 122 123 t1 = Teacher("日天",28,30000,"讲师","教学部",py_course,headquarter) 124 t2 = Teacher("Egon",28,30000,"讲师","教学部",linux_course,sh1_school) 125 t3 = Teacher("佩奇",29,40000,"学科带头人","教学部",py_course,sh2_school) 126 127 stu1 = Student("春生",22,class1,50000) 128 stu2 = Student("black girl",22,class3,30000) 129 stu3 = Student("小强",22,class2,35000) 130 131 132 for i in (stu1,stu2,stu3): 133 i.pay_tuition() 134 print(class1.stu_list) 135 136 sh1_school.show_balance() 137 sh2_school.show_balance() 138 luffy.show_balance() 139 140 headquarter.count_total_revenue() 141 headquarter.count_staff_num()
Aiden的技术屋 文章被收录于专栏
虽然还是个菜鸟,但是总有一天会长大,翱翔于天空,热爱技术