-管理员视图 1、注册 2、登录 3、创建学校 4、创建课程(选择学校) 5、创建讲师 -学员视图 1、登录 2、注册 3、选择校区 4、选择课程(线选择校区) 课程也选择学生,双向绑定 5、查看分数 -讲师视图 1、登录 2、查看教授课程 3、选择教授课程 4、查看课程学生 5、修改学生分数
-三层架构 -用户视图层 -用户交互 -做一些小的逻辑判断 -core -src 逻辑接口层 -核心业务逻辑 -db -dbhandler student_interface tercher_interface anmin_interface 数据处理层 -数据的处理,增、删、改、查 pickle--序列化--保存对象
'''
以上内容搞定我们就可以去设计我们的目录结构了
conf--配置文件
core--视图层
db--数据处理
interface--接口层
lib--common--存放程序的公共方法
start.py--程序启动入口
接下来写视图层的代码、可以理解为给用户看的软件菜单
视图层(src)--管理员视图(admin)、学生视图(student)、老师视图(teacher)、
'''src.py ''' from core import admin 2 from core import student 3 from core import teacher 4 5 '''创建功能字典''' 6 func_dict={ 7 '1':admin.admin_view, 8 '2':student.student_view, 9 '3':teacher.teacher_view, 10 } 11 12 def run(): 13 while True: 14 print('欢迎来到选课系统'.center(32, '*')) 15 print(''' 16 1、管理员功能 17 2、学生功能 18 3、老师功能 19 ''') 20 choice = input('请输入功能编号:退出请按【q】').strip() 21 if choice == 'q' or choice == 'Q': 22 break 23 if choice not in func_dict: 24 print('输入错误,请重新输入:') 25 else: 26 func_dict[choice]()
管理员视图
'''admin.py''' #功能字典 2 func_dict={ 3 '1': register, 4 '2': login, 5 '3': create_school, 6 '4': create_course, 7 '5': create_teacher, 8 } 9 10 #管理员视图内容 11 def admin_view(): 12 while True: 13 print('欢迎来到管理员页面'.center(32, '*')) 14 print(''' 15 1、注册 16 2、登录 17 3、创建学校 18 4、创建课程(选择学校) 19 5、创建讲师 20 ''') 21 choice = input('请输入功能编号:').strip() 22 if choice == 'q' or choice == 'Q': 23 break 24 if choice not in func_dict: 25 print('输入错误,请重新输入:') 26 else: 27 func_dict[choice]()
学生视图
'''student.py''' func_dict={ 2 '1': register, 3 '2': login, 4 '3': choice_school, 5 '4': choice_course, 6 } 7 8 def student_view(): 9 while True: 10 print('欢迎来到学生页面'.center(32,'*')) 11 print(''' 12 1、登录 13 2、注册 14 3、选择校区 15 4、选择课程(线选择校区) 16 ''') 17 choice = input('请输入功能编号:').strip() 18 if choice == 'q' or choice == 'Q': 19 break 20 if choice not in func_dict: 21 print('输入错误,请重新输入:') 22 else: 23 func_dict[choice]()
老师视图
'''student.py''' func_dict={ 2 '1': login, 3 '2': check_course, 4 '3': choose_course, 5 '4': check_student, 6 '5': change_score 7 } 8 9 def teacher_view(): 10 while True: 11 print('欢迎来到老师页面'.center(32, '*')) 12 print(''' 13 1、登录 14 2、查看教授课程 15 3、选择教授课程 16 4、查看课程学生 17 5、修改学生分数 18 ''') 19 choice = input('请输入功能编号:').strip() 20 if choice == 'q' or choice == 'Q': 21 break 22 if choice not in func_dict: 23 print('输入错误,请重新输入:') 24 else: 25 func_dict[choice]()
程序启动
'''start.py''' '''启动程序入口''' 2 3 import os, sys 4 sys.path.append(os.path.dirname(__file__)) 5 6 from core import src 7 8 9 if __name__ == '__main__': 10 src.run()
这样程序结构基本做完了,接下来就是一步一步去实现功能了
下面的程序,是整个选课系统的完整代码:学习面向对象编程建议新手都要敲至少两次,总结其中的每一个知识点,这样才能把别别人的技术转化为自己的技术储备