培训学校管理系统

1.定模型(类)

  • 总部

  • 分校

  • 员工

  • 老师

  • 学员

  • 课程

  • 班级

    2.定属性

  • 总部

    • 名字、地址、电话、网址

    • 银行账户

    • 员工列表

    • 学员列表

    • 分校列表

    • 发工资

    • 开分校

    • 开课

    • 开班

    • 招聘

    • 统计账户余额

    • 统计员工人数

    • 统计学员人数

  • 分校

    • 继承总校
  • 员工

    • 姓名、年龄、职务、部门、工资、所属校区、入职时间
  • 老师

    • 继承员工
    • 上课
  • 学员

    • 姓名、年龄、学历
    • 班级
    • 账户余额
  • 课程

    • 名称
    • 价格
    • 学历要求
    • 大纲
  • 班级

    • 校区
    • 编号
    • 开设课程
    • 开课日期
    • 学员列表
    • 学员退学、转学

3.定关系

  • 总部 –> 分校
  • 学员 –> 班级
  • 课程 –> 班级
  • 班级 –> 分校
  • 老师 –> 员工
  • 老师 –> 课程

4.画UML图
5.写代码

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
class School:
"""学校总部"""
def __init__(self, name, addr, phone, website):
self.name = name
self.addr = addr
self.phone = phone
self.website = website
self.branches = {}
self.__staff_list = []
self.__stu_list = []
self.__bank_account_balance = 0
print('初始化校区{},地址:{},电话:{},网址:{}'.format(self.name, self.addr, self.phone, self.website))

def count_staff_num(self):
"""统计各分校员工数"""
total_staff_num = len(self.__staff_list)
return total_staff_num

def count_stu_num(self):
"""统计学员数"""
total_stu_num = len(self.__stu_list)
return total_stuf_num

def pay_roll(self):
"""发工资"""
pass

def new_staff_enrollment(self, staff_obj):
"""添加员工"""
self.__staff_list.append(staff_obj)

def open_course(self):
"""开课"""
pass

def open_class(self):
"""开班"""
pass

class BranchSchool(School):
def __init__(self, name, addr, phone, headquater_obj):
super().__init__(website)
self.headquater_obj = headquater_obj
self.headquater_obj.branches[name] = self



headquater = School("达外北京总部","亦庄凉水河一街9号","010-87228722","www.dawai.cn")


初始化校区达外北京总部,地址:亦庄凉水河一街9号,电话:010-87228722,网址:www.dawai.cn
  1. 完成所有类代码
  2. 初始化总部
  3. 初始化北京分校、上海分校、上海一分校、上海二分校
  4. 初始化三门课程
  5. 初始化三个班级
  6. 初始化若干员工
  7. 初始化若干教师
  8. 初始化若干学员
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
import time
class School(object):
"""学校基类,总部校区"""
def __init__(self,name,addr):
self.name = name
self.addr = addr
self.branches = {} # 下属分校
self.__staff_list = [] # 员工列表
self.__bank_account_balance = 0 # 财务账号
print("初始化校区[%s],地址:%s..." % (self.name,self.addr))
def count_staff_num(self):
"""统计公司各分校员工人数"""
total_staff_num = len(self.__staff_list)
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 pay_roll(self):
"""发工资"""
def new_staff_enrollment(self,staff_obj):
"""添加新员工"""
self.__staff_list.append(staff_obj)
def count_total_balance(self):
balance = self.__bank_account_balance
for branch_name,branch_obj in self.branches.items():
balance += branch_obj.__bank_account_balance
print("Total balance:",balance)
def open_course(self):
pass
def open_class(self):
pass
def show_balance(self):
print("[%s]账户余额:%s" %( self.name,self.__bank_account_balance))
def money_transfer_in(self,amount,from_obj,purpose):
"""
收钱
:param amount:
:param from_obj:
:param purpose:
:return:
"""
self.__bank_account_balance += amount
print("%s,校区[%s]收到[%s]转账[%s],交费原因[%s]..." % (time.strftime("%Y-%m-%d %H:%M:%S"),
self.name,from_obj.name,amount,purpose))
class BranchSchool(School):
"""分校"""
def __init__(self,name,addr,headquater_obj):
super().__init__(name,addr)
self.headquater_obj = headquater_obj # 总部的对象
self.headquater_obj.branches[name] = self # 把自己添加到总部的分校列表
class Course(object):
"""课程类"""
def __init__(self,name,fee,degree_requirement,):
self.name = name
self.fee = fee # 学费
self.degree_requirement = degree_requirement # 学历要求
class Class(object):
"""班级类"""
def __init__(self,course_obj,school_obj,class_num,start_date):
self.class_num = class_num # 班级编号
self.start_date = start_date # 开班日期
self.course_obj = course_obj # 开设的课程
self.school_obj = school_obj # 所在校区
self.stu_list = [] # 学员列表
print("校区[%s]开设了[%s]课程第[%s]班,开班日期[%s]..." %( school_obj.name ,course_obj.name ,class_num,start_date))
def get_class_name(self):
return "%s-%s-s%s期" %(self.school_obj.name,self.course_obj.name,self.class_num)
def drop_out(self,stu_obj):
"""退学"""
self.stu_list.remove(stu_obj)
print("学员[%s]从[%s]退学了...." % (stu_obj.name,self.get_class_name()))
class Staff(object):
"""员工类"""
def __init__(self,name,age,position,salary,dept,school_obj,on_board_date):
self.name = name
self.age = age
self.position = position # 职位
self.salary = salary
self.dept = dept # 部门
self.school_obj = school_obj # 所属校区
self.on_board_date = on_board_date # 入职日期
print("校区[%s]的[%s]部门在[%s]入职一名新同事[%s],职位是[%s]" % (school_obj.name ,dept,on_board_date, name,position))
school_obj.new_staff_enrollment(self)
class Teacher(Staff):
"""讲师"""
def teaching(self,class_obj):
"""
上课
:param class_obj: 上课的班级
"""
pass
class Student(object):
def __init__(self,name,age,degree,class_obj,balance):
self.name = name
self.age = age
self.degree = degree
self.class_obj = class_obj # 报名班级对象
self.balance = balance # 这个学生账户余额
self.class_obj.stu_list.append(self) # 添加学生到这个班级
def pay_tuition(self):
"""交学费"""
self.balance -= self.class_obj.course_obj.fee # 交学费
self.class_obj.school_obj.money_transfer_in(self.class_obj.course_obj.fee,self,"交%s学费"%self.class_obj.get_class_name())
def __repr__(self):
return "学生:%s,班级:%s" %(self.name,self.class_obj.get_class_name())

# 初始化总部及校区
headquater = School("达外北京总部","北京凉水河一街9号")
bj1 = BranchSchool("达外北京分校","北京亦庄经济技术开发区",headquater)
sh = BranchSchool("达外上海分校","上海张江科技园",headquater)
sh1 = BranchSchool("达外上海1分校","上海虹桥机场",sh)
sh2 = BranchSchool("达外上海2分校","上海虹桥火车站",sh)
sz1 = BranchSchool("达外深圳分校","深圳南山大学城1号",headquater)

# 初始化员工
staff1 = Staff("王达外",32,"CEO",60000,"总经办",headquater,"2017-05-22")
staff2 = Staff("周达内",23,"HR",6000,"HR",headquater,"2018-03-12")
t1 = Teacher("马骏",27,"前端开发讲师",30000,"教研部",bj1,"2018-02-26")
t2 = Teacher("牛牡",25,"Python讲师",45000,"教研部",sz1,"2018-07-14")
t3 = Teacher("张弛",23,"Go讲师",40000,"教研部",sh1,"2018-07-14")
# 初始化课程
py_course = Course("Python开发",21800,"本科")
linux_course = Course("Linux云计算运维",19800,"专科")
go_course = Course("GO开发",9800,"本科")
# 初始化班级
class1 = Class(py_course,bj1,21,"2019-07-06")
class2 = Class(linux_course,sz1,4,"2019-06-16")
class3 = Class(go_course,sh1,11,"2019-09-21")
# 初始化学员
stu1 = Student("孙小空",22,"本科",class1,30000)
stu2 = Student("朱小戒",23,"专科",class2,25000)
stu3 = Student("沙小僧",26,"本科",class3,13000)
stu4 = Student("刘小贝",21,"本科",class3,10000)
stu5 = Student("张小飞",21,"专科",class1,20000)
for i in (stu1,stu2,stu3,stu4):
i.pay_tuition()
print(class3.stu_list)
bj1.show_balance()
sh1.show_balance()
sh2.show_balance()
sz1.show_balance()
headquater.count_total_balance()
headquater.count_staff_num()
print(headquater.branches)
# 退学
stu5.class_obj.drop_out(stu5)
初始化校区[达外北京总部],地址:北京凉水河一街9号...
初始化校区[达外北京分校],地址:北京亦庄经济技术开发区...
初始化校区[达外上海分校],地址:上海张江科技园...
初始化校区[达外上海1分校],地址:上海虹桥机场...
初始化校区[达外上海2分校],地址:上海虹桥火车站...
初始化校区[达外深圳分校],地址:深圳南山大学城1号...
校区[达外北京总部]的[总经办]部门在[2017-05-22]入职一名新同事[王达外],职位是[CEO]
校区[达外北京总部]的[HR]部门在[2018-03-12]入职一名新同事[周达内],职位是[HR]
校区[达外北京分校]的[教研部]部门在[2018-02-26]入职一名新同事[马骏],职位是[前端开发讲师]
校区[达外深圳分校]的[教研部]部门在[2018-07-14]入职一名新同事[牛牡],职位是[Python讲师]
校区[达外上海1分校]的[教研部]部门在[2018-07-14]入职一名新同事[张弛],职位是[Java讲师]
校区[达外北京分校]开设了[Python开发]课程第[21]班,开班日期[2019-07-06]...
校区[达外深圳分校]开设了[Linux云计算运维]课程第[4]班,开班日期[2019-06-16]...
校区[达外上海1分校]开设了[GO开发]课程第[11]班,开班日期[2019-09-21]...
2019-10-16 09:55:31,校区[达外北京分校]收到[孙小空]转账[21800],交费原因[交达外北京分校-Python开发-s21期学费]...
2019-10-16 09:55:31,校区[达外深圳分校]收到[朱小戒]转账[19800],交费原因[交达外深圳分校-Linux云计算运维-s4期学费]...
2019-10-16 09:55:31,校区[达外上海1分校]收到[沙小僧]转账[9800],交费原因[交达外上海1分校-GO开发-s11期学费]...
2019-10-16 09:55:31,校区[达外上海1分校]收到[刘小贝]转账[9800],交费原因[交达外上海1分校-GO开发-s11期学费]...
[学生:沙小僧,班级:达外上海1分校-GO开发-s11期, 学生:刘小贝,班级:达外上海1分校-GO开发-s11期]
[达外北京分校]账户余额:21800
[达外上海1分校]账户余额:19600
[达外上海2分校]账户余额:0
[达外深圳分校]账户余额:19800
Total balance: 41600
[达外北京分校]总员工数量:1
[达外上海1分校]总员工数量:1
[达外上海2分校]总员工数量:0
[达外上海分校]总员工数量:1
[达外深圳分校]总员工数量:1
[达外北京总部]总员工数量:5
{'达外北京分校': <__main__.BranchSchool object at 0x1049a2c50>, '达外上海分校': <__main__.BranchSchool object at 0x1049a2e10>, '达外深圳分校': <__main__.BranchSchool object at 0x1049a2ef0>}
学员[张小飞]从[达外北京分校-Python开发-s21期]退学了....
1

评论

:D 一言句子获取中...

加载中,最新评论有1分钟缓存...