""" 校园管理系统 设计一个培训机构管理系统,有总部、分校,有学员、老师、员工,实现具体如下需求: 1. 有多个课程,课程要有定价 2. 有多个班级,班级跟课程有关联 3. 有多个学生,学生报名班级,交这个班级对应的课程的费用 4. 有多个老师,可以分布在不同校区,上不同班级的课 5. 有多个员工,可以分布在不同校区在总部可以统计各校区的账户余额、员工人数、学员人数 6. 学生可以转校、退学 """ import time #导入时间模块 #定义个学校 class School: #初始化 def __init__(self,name,address): self.name = name self.address = address self.branches = {} #统计分校的信息 self.staff_lst = [] #员工总数存在列表里 self.class_list = [] #学员列表 self.__money_account = 0 #初始的费用为0,后面进行计费 #发工资 def pay_roll(self): print("给大家发工资了") #统计员工人数 def count_staff_num(self): """统计公司各分校员工人数""" total_staff_num = len(self.staff_lst) #员工列表的长度用来计算总校总员工数 for i in self.branches: #遍历分校,分别计算 total_staff_num += self.branches[i].count_staff_num() # 统计分校人数 print("[%s]总员工数量:%s" % (self.name, total_staff_num)) return total_staff_num def count_student_num(self): """统计学员总数人数""" total_student_num = 0 for i in self.class_list: #遍历学员列表 total_student_num += len(i.stu_lst) # 统计分校人数 print("[%s]总学员数量:%s" % (self.name, total_student_num)) #新员工注册 def new_staff_enrollment(self,staff_obj): self.staff_lst.append(staff_obj) #将员工加入列表 # 统计学员人数 # 统计总的费用 def count_account(self): balance = self.__money_account for i,v in self.branches.items(): balance += v.__money_account print(f"总钱数:{balance}") #收钱方法 def collect_fee(self,amount,name_obj,cause): self.__money_account += amount # print(f"{time.strptime('%Y-%m-%d %H:%M:%S')}{self.name}校区收到{name_
校园管理系统
最新推荐文章于 2023-12-28 09:15:00 发布