Python作业选课系统(第六周)
作业需求:
角色:学校、学员、课程、讲师、完成下面的要求
1. 创建北京、上海 2 所学校
2. 创建linux , python , go 3个课程 , linux\py 在北京开, go 在上海开
3. 课程包含,周期,价格,通过学校创建课程
4. 通过学校创建班级, 班级关联课程、讲师
5. 创建学员时,选择学校,关联班级
5. 创建讲师角色时要关联学校,
6. 提供两个角色接口
6.1 学员视图, 可以注册, 交学费, 选择班级,
6.2 讲师视图, 讲师可管理自己的班级, 上课时选择班级, 查看班级学员列表 , 修改所管理的学员的成绩
6.3 管理视图,创建讲师, 创建班级,创建课程
7. 上面的操作产生的数据都通过pickle序列化保存到文件里
思路(简单整理)
关联关系:
1.学校-班级
2. 班级-课程-讲师
3.讲师-学校
4.学生-学校-班级-(这里隐藏了一个关联关系就是班级还关联这-课程-讲师)
分析后得出5个类,学校,课程,班级,讲师,学生,创建这5个类,然后用学校类将关联关系理清,然后用三个视图调用不同对象进行操作。
简单流程图:
README:
- 作者:yaobin
- 版本:示例版本 v0.1 mmp版本 :(
- 程序介绍:
- 1. 创建北京、上海 2 所学校
- 2. 创建linux , python , go 3个课程 , linux\py 在北京开, go 在上海开
- 3. 课程包含,周期,价格,通过学校创建课程
- 4. 通过学校创建班级, 班级关联课程、讲师
- 5. 创建学员时,选择学校,关联班级
- 5. 创建讲师角色时要关联学校,
- 6. 提供两个角色接口
- 6.1 学员视图, 可以注册, 交学费, 选择班级,
- 6.2 讲师视图, 讲师可管理自己的班级, 上课时选择班级, 查看班级学员列表 , 修改所管理的学员的成绩
- 6.3 管理视图,创建讲师, 创建班级,创建课程
- 7. 上面的操作产生的数据都通过pickle序列化保存到文件里
- 文件目录
- ---选课系统 #主程序目录
- │ README
- │ __init__.py
- │
- ├─bin
- │ Course_Selecting.py #主程序
- │ __init__.py
- │
- ├─conf
- │ │ setting.py #配置文件
- │ │ __init__.py
- │
- ├─core
- │ │ main.py #主逻辑交互程序
- │ │ school_view.py #学校视图
- │ │ student_view.py #学生视图
- │ │ teacher_view.py #老师视图
- │ │ __init__.py
- │
- ├─db
- │ 1.py
- │ school.bak
- │ school.dat #数据db
- │ school.dir
- │
- ├─logs
- │ __init__.py
- │
- ├─src
- │ │ class_classroom.py #教室类
- │ │ class_course.py #课程类
- │ │ class_school.py #学校类
- │ │ class_student.py #学生类
- │ │ class_teacher.py #老师类
- │ │ __init__.py
- │
- └─test
- __init__.py
代码部分:
bin / Course_Selecting.py
- #!/usr/bin/env python
- # -*- coding:utf-8 -*-
- # Author: Colin Yao
- import os,sys,logging,shelve
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- sys.path.append(BASE_DIR) #添加环境变量
- from conf import setting
- from core.main import Admin
- if __name__ == '__main__':
- Admin.run('')
conf / setting.py
- #!/usr/bin/env python
- # -*- coding:utf-8 -*-
- # Author: Colin Yao
- import os,time,shelve,sys
- from src.class_school import School
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- sys.path.append(BASE_DIR) #添加环境变量
- data_path = os.path.join(BASE_DIR+'\db')
- school_file = os.path.join(data_path,'school')
core / main.py
- #!/usr/bin/env python
- # -*- coding:utf-8 -*-
- # Author: Colin Yao
- import os,sys,logging,shelve
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- sys.path.append(BASE_DIR) #添加环境变量
- from conf import setting
- from core.school_view import School_view
- from core.teacher_view import Teacher_view
- from core.student_view import Student_view
- class Admin(object):
- def run(self):
- exit_flag =False
- menu = u'''
- \033[32;1m
- 1.学生视图
- 2.老师视图
- 3.学校视图
- 4.退出\033[0m
- '''
- while not exit_flag:
- print(menu)
- user_option = input('请输入要管理的视图,输入q退出>>>:\t')
- if user_option == '':
- Student_view()
- elif user_option == '':
- Teacher_view()
- elif user_option == '':
- School_view()
- elif user_option == 'q' or user_option =='':
- sys.exit()
- else:
- print('输入的选项不正确,请重新输入')
school_view.py
- #!/usr/bin/env python
- # -*- coding:utf-8 -*-
- # Author: Colin Yao
- import os,sys,logging,shelve
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- sys.path.append(BASE_DIR) #添加环境变量
- from conf import setting
- from src.class_school import School
- class School_view(object):
- def __init__(self):
- if os.path.exists(setting.school_file+ '.dat'):
- self.school_file = shelve.open(setting.school_file)
- self.school_manger()
- self.school_file.close()
- else:
- print('没有学校和班级的数据,请先创建')
- self.init_school()
- self.school_manger()
- self.school_file.close()
- def init_school(self):
- self.school_file = shelve.open(setting.school_file)
- self.school_file['北京'] = School('总校','北京')
- self.school_file['上海'] = School('总校','上海')
- def school_manger(self):
- while True:
- for school_name in self.school_file:
- print('学校名称:%s'%school_name)
- school_option = input('请输入要管理的学校名称>>>:').strip()
- if school_option in self.school_file:
- self.school_option = school_option
- self.school_obj = self.school_file[school_option]
- '''
- 如果是北京就等于self.school_obj[北京]
- file[北京] =School('总校','北京')
- 所以当下文出现了self.school_obj.school_course =School('总校','北京').school_course
- 等同于调用了School().school_course的属性是
- '''
- while True:
- menu = '''
- 欢迎来到 Python%s校区
- 添加课程 add_course
- 添加班级 add_classroom
- 添加讲师 add_teacher
- 查看班级 show_classroom
- 查看课程 show_classroom
- 查看讲师 show_teacher
- 修改讲师 add_teacher
- 退出 exit
- '''%school_option
- print(menu)
- user_choice = input('请选择以上操作>>>:').strip()
- if hasattr(self,user_choice):
- getattr(self,user_choice)()
- else:
- print("没有这个操作,请重新输入!!!!")
- pass
- def add_course(self):
- course_name = input('请输入课程名称>>>:').strip()
- course_price = input('请输入课程价格>>>:').strip()
- course_time = input('请输入课程周期[默认为周]>>>:').strip()
- if course_name in self.school_obj.school_course:
- print('课程已经存在')
- else:
- self.school_obj.create_course(course_name, course_price, course_time) #相当于School.create_course(course_name, course_price, course_time)
- print('%s课程添加成功' % course_name)
- self.school_file.update({self.school_option:self.school_obj})
- self.school_file.close()
- def add_classroom(self):
- class_name = input('请输入班级名称>>>:').strip()
- class_course = input('请输入课程>>>:').strip()
- if class_name not in self.school_obj.sch_class_room: #sch_class_room
- if class_name not in self.school_obj.school_course:
- course_obj = self.school_obj.school_course[class_course]
- self.school_obj.create_classroom(class_name,course_obj)
- self.school_file.update({self.school_option:self.school_obj})
- self.school_file.close()
- print('班级创建成功')
- else:
- print('课程不存在')
- else:
- print('班级已经存在')
- def show_classroom(self):
- for classroom in self.school_obj.sch_class_room:
- class_obj = self.school_obj.sch_class_room[classroom]
- print('班级名称:%s\t课程:%s'
- % (class_obj.class_name,class_obj.course_obj.course_name))
- def add_teacher(self):
- teacher_name = input('请输入讲师姓名>>>:')
- teacher_age = input('请输入讲师年龄>>>:')
- teacher_gender = input('请输入讲师性别>>>:')
- teacher_salary = input('请输入讲师薪水>>>:')
- class_name = input('请输入授课班级>>>:')
- if class_name in self.school_obj.sch_class_room: # sch_class_room
- class_obj = self.school_obj.sch_class_room[class_name]
- if teacher_name not in self.school_obj.sch_teacher:
- self.school_obj.create_teacher(teacher_name,teacher_age,teacher_gender,teacher_salary,class_name,class_obj)
- print('讲师创建成功,请确认是否已经签完合同')
- else:
- self.school_obj.modify_teacher({})
- print('修改讲师成功')
- self.school_file.update({self.school_option:self.school_obj})
- self.school_file.close()
- else:
- print('请先创建班级')
- def show_teacher(self):
- for teacher_name in self.school_obj.sch_teacher:
- teacher_obj = self.school_obj.sch_teacher[teacher_name]
- for t in teacher_obj.teacher_classroom:
- class_obj = self.school_obj.sch_class_room[t]
- stu_list = []
- for j in class_obj.class_student:
- stu_list.append(j)
- print('教师姓名:%s\t教师所在班级:%s\t教授课程:%s\t课程学员:%s' %(teacher_obj.teacher_name
- ,t,class_obj.course_obj.course_name,class_obj.class_student))
- def exit(self):
- sys.exit('程序退出')
student_view.py
- #!/usr/bin/env python
- # -*- coding:utf-8 -*-
- # Author: Colin Yao
- import os, sys, logging, shelve
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- sys.path.append(BASE_DIR) # 添加环境变量
- from conf import setting
- from src.class_school import School
- from core.school_view import School_view
- class Student_view(object):
- def __init__(self):
- if os.path.exists(setting.school_file+ '.dat'):
- self.school_file = shelve.open(setting.school_file)
- self.student_manger()
- self.school_file.close()
- else:
- print('没有数据,请联系管理员选择分校')
- sys.exit()
- def student_manger(self):
- while True:
- print('欢迎注册IT学院我们的分校有:')
- for school_name in self.school_file:
- print('\tSean[%s]分校' %school_name)
- school_option = input('请输入您要学习的分校地址>>>:').strip()
- if school_option in self.school_file:
- self.school_option = school_option
- self.school_obj = self.school_file[school_option]
- else:
- print('输入有误程序退出')
- sys.exit()
- for classroom in self.school_obj.sch_class_room:
- class_obj = self.school_obj.sch_class_room[classroom]
- print('欢迎来到%s分校我们的班级有:%s\t课程有:%s'
- % (school_option, class_obj.class_name, class_obj.course_obj.course_name))
- student_option = input('请输入学生姓名进行操作[PS:注册也在这里哟]>>>:').strip()
- if student_option in self.school_obj.sch_student:
- self.student_option = student_option
- self.student_obj = self.school_obj.sch_student[self.student_option]
- else:
- print('[%s]这位童鞋'%student_option,'您是否进行注册?')
- user_choice = input('请注册/退出(y/n)>>>:')
- if user_choice == 'y':
- self.student_option = student_option
- self.enroll()
- elif user_choice == 'n':
- sys.exit()
- else:
- print('输入有误,请重新开始 = 。= ')
- self.student_manger()
- while True:
- menu = '''
- 欢迎来到 Python[%s]校区[%s]童鞋
- 缴纳学费 pay
- 选择教室/课程 choice_class
- 查看讲师 view_teacher
- 退出 exit
- ''' %(school_option,student_option)
- print(menu)
- user_choice = input('请选择以上操作>>>:').strip()
- if hasattr(self, user_choice):
- getattr(self, user_choice)()
- else:
- print("没有这个操作,请重新输入!!!!")
- pass
- '''注册'''
- def enroll(self): # 课程、班级
- student_name = self.student_option
- student_gender = input('%s童鞋请输入性别>>>:' % student_name)
- student_age = input('%s童鞋请输入年纪>>>:' % student_name)
- class_name = input('%s童鞋请输入教室(PS:教室已经和课程关联)>>>:' % student_name)
- student_score = None
- if class_name in self.school_obj.sch_class_room:
- class_obj = self.school_obj.sch_class_room[class_name]
- self.school_obj.create_student(student_name, student_gender, student_age, student_score, class_name)
- self.school_file.update({self.school_option: self.school_obj})
- self.school_file.close()
- print('%s童鞋注册成功,您选择的课程是%s,教室为%s'
- % (student_name, class_obj.course_obj.course_name, class_obj.class_name))
- else:
- print('创建失败教室不存在')
- '''缴纳学费'''
- def pay(self): # 根据教室缴纳学费
- student_name = self.student_option
- class_name = input('%s童鞋请输入您所在的教室(PS:教室已经和课程关联)>>>:' % student_name)
- if class_name in self.school_obj.sch_class_room: # sch_class_room
- class_obj = self.school_obj.sch_class_room[class_name]
- if class_obj.course_obj.course_name in self.school_obj.school_course:
- course_obj = self.school_obj.school_course[class_obj.course_obj.course_name]
- print('所在分校:%s\t课程名称:%s\t课程价格:%s\t课程学习计划:%s周'
- % (self.school_obj.school_addr, course_obj.course_name, course_obj.course_price, course_obj.course_time))
- '''选择班级'''
- def choice_class(self): # 根据学习日期选择班级
- student_name = self.student_option
- student_gender = self.student_obj.student_gender
- student_age = self.student_obj.student_age
- class_name = input('%s童鞋选择教室(PS:教室已经和课程关联)>>>:' % student_name)
- student_score = 0
- # class_name ='room'
- if class_name in self.school_obj.sch_class_room: # sch_class_room
- class_obj = self.school_obj.sch_class_room[class_name]
- self.school_obj.create_student(student_name, student_gender, student_age, student_score, class_name)
- self.school_file.update({self.school_option: self.school_obj})
- self.school_file.close()
- print('%s更改教室成功,您选择的课程是%s,教室为%s'
- % (student_name, class_obj.course_obj.course_name, class_obj.class_name))
- else:
- print('创建失败教室不存在')
- '''查看讲师'''
- def view_teacher(self):
- for teacher_name in self.school_obj.sch_teacher:
- teacher_obj = self.school_obj.sch_teacher[teacher_name]
- for t in teacher_obj.teacher_classroom:
- class_obj = self.school_obj.sch_class_room[t]
- stu_list = []
- for j in class_obj.class_student:
- stu_list.append(j)
- print('教师姓名:%s\t教师所在班级:%s\t教授课程:%s\t学生有%s'
- % (teacher_obj.teacher_name,t, class_obj.course_obj.course_name,stu_list))
- '''退出'''
- def exit(self):
- sys.exit('感谢使用再见')
teacher_view.py
- #!/usr/bin/env python
- # -*- coding:utf-8 -*-
- # Author: Colin Yao
- import os,sys,logging,shelve
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- sys.path.append(BASE_DIR) #添加环境变量
- from conf import setting
- from src.class_school import School
- class Teacher_view(object):
- def __init__(self):
- if os.path.exists(setting.school_file+ '.dat'):
- self.school_file = shelve.open(setting.school_file)
- self.teacher_manger()
- self.school_file.close()
- else:
- print('没有教师数据,请先创建学校')
- sys.exit()
- def teacher_manger(self):
- while True:
- print('欢迎进入IT学院讲师视图:')
- for school_name in self.school_file:
- print('讲师分校名:%s' % school_name)
- school_option = input('请输入您所在分校名>>>:').strip()
- if school_option in self.school_file:
- self.school_option = school_option
- self.school_obj = self.school_file[school_option]
- else:
- print('您的输入有误')
- break
- teacher_option = input('请输入讲师姓名进行管理>>>:').strip()
- if teacher_option in self.school_obj.sch_teacher:
- self.teacher_option = teacher_option
- self.teacher_obj = self.school_obj.sch_teacher[self.teacher_option]
- print('欢迎讲师%s进入讲师管理系统以下是您的讲师信息:'
- '\n讲师姓名:%s\t讲师年龄:%s\t讲师性别:%s\t讲师工资:%s'
- %(self.teacher_obj.teacher_name,self.teacher_obj.teacher_name
- ,self.teacher_obj.teacher_age,self.teacher_obj.teacher_gender,self.teacher_obj.teacher_salary))
- else:
- print('没有[%s]这位讲师'%teacher_option)
- sys.exit()
- while True:
- menu = '''
- 欢迎来到 Python[%s]校区[%s]讲师
- 选择教室 management_class
- 查看班级 view_class
- 查看学员 view_student_list
- 修改成绩 revise_student_grades
- 退出 exit
- ''' %(school_option,teacher_option)
- print(menu)
- user_choice = input('请选择以上操作>>>:').strip()
- if hasattr(self, user_choice):
- getattr(self, user_choice)()
- else:
- print("没有这个操作,请重新输入!!!!")
- pass
- '''管理自己的班级'''
- def management_class(self):
- for classroom in self.teacher_obj.teacher_classroom:
- class_obj = self.teacher_obj.teacher_classroom[classroom] #教室对象
- print('%s您所在的班级为:%s\t教授的课程是%s:' % (self.teacher_obj.teacher_name,
- class_obj.class_name,class_obj.course_obj.course_name)) # 讲师对应教室和课程
- user_choice = input('是否选择要上课的教室y/n>>>:').strip()
- if user_choice == 'y':
- class_name = input('请输入要上课的教室>>>:').strip()
- class_obj = self.school_obj.sch_class_room[class_name]
- self.school_obj.create_teacher(self.teacher_obj.teacher_name, self.teacher_obj.teacher_age,
- self.teacher_obj.teacher_gender,self.teacher_obj.teacher_salary,class_name,
- class_obj)
- print('讲师选择教室对应的课程成功')
- self.school_file.update({self.school_option:self.school_obj})
- self.school_file.close()
- elif user_choice == 'n':
- print('不对班级进行管理....请重新选择您的操作!!!>>>:')
- pass
- else:
- print('输入不正确')
- pass
- '''上课选择班级和管理班级'''
- def view_class(self): # 上课选择班级,
- for classroom in self.teacher_obj.teacher_classroom:
- class_obj = self.teacher_obj.teacher_classroom[classroom] # 教室对象
- print('%s您所在的班级为:%s\t教授的课程是%s:' % (self.teacher_obj.teacher_name,
- class_obj.class_name, class_obj.course_obj.course_name)) # 讲师对应教室和课程
- '''查看学员列表'''
- def view_student_list(self): # 查看学员列表
- for classroom in self.teacher_obj.teacher_classroom:
- class_obj = self.teacher_obj.teacher_classroom[classroom] # 教室对象
- stu_list = []
- for j in class_obj.class_student:
- stu_list.append(j)
- print('%s您所在的班级为:%s\t教授的课程是%s\t您班级里的学生有%s:' % (self.teacher_obj.teacher_name,
- class_obj.class_name, class_obj.course_obj.course_name,
- stu_list)) # 讲师对应教室和课程有问题
- '''修改成绩'''
- def revise_student_grades(self):
- self.view_student_list()
- for classroom in self.teacher_obj.teacher_classroom:
- class_obj = self.school_obj.sch_class_room[classroom] # 教室对象
- student_name = input('请讲师修改成绩的学生的姓名>>>:').strip()
- if student_name in class_obj.class_student:
- student_obj = class_obj.class_student[student_name]
- print('%s童鞋成绩为%s\t课程:%s\t教室:%s'
- %(student_name, student_obj.student_score, class_obj.course_obj.course_name, class_obj.class_name))
- student_gender = student_obj.student_gender
- student_age = student_obj.student_age
- new_score = input('请讲师修改成绩>>>:').strip()
- self.school_obj.create_student\
- (student_name, student_gender, student_age, new_score,class_obj.class_name)
- self.school_file.update({self.school_option: self.school_obj})
- self.school_file.close()
- print('%s童鞋修改成功,他的成绩为%s,他的课程是%s,教室为%s'
- % (student_name, new_score, class_obj.class_name, class_obj.course_obj.course_name))
- else:
- print('没有这个童鞋>>>>>!!!!')
- def exit(self):
- sys.exit('[%s]讲师感谢使用再见'%self.teacher_obj.teacher_name)
db
logs
src / class_classroom.py
- #!/usr/bin/env python
- # -*- coding:utf-8 -*-
- # Author: Colin Yao
- import time
- '''班级类'''
- class Class_room(object):
- def __init__(self,class_name,course_obj):
- self.class_name = class_name
- self.course_obj = course_obj
- self.class_student = {}
class_course.py
- #!/usr/bin/env python
- # -*- coding:utf-8 -*-
- # Author: Colin Yao
- '''课程类'''
- import time
- class Course(object):
- def __init__(self,course_name,course_price,course_time):
- self.course_name = course_name
- self.course_price = course_price
- self.course_time = course_time
class_school.py
- #!/usr/bin/env python
- # -*- coding:utf-8 -*-
- # Author: Colin Yao
- import time,os,shelve,sys
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- sys.path.append(BASE_DIR) #添加环境变量
- from src.class_teacher import Teacher
- from src.class_course import Course
- from src.class_classroom import Class_room
- from src.class_student import Student
- '''学校类'''
- class School(object):
- def __init__(self,school_name,school_addr):
- self.school_name = school_name
- self.school_addr = school_addr
- self.school_course = {}
- self.sch_class_room ={}
- self.sch_teacher = {}
- self.sch_student = {}
- '''创建课程'''
- def create_course(self,course_name,course_price,course_time):
- course_obj = Course(course_name,course_price,course_time) #创建课程对象
- self.school_course[course_name] = course_obj #根据课程名为key,课程对象为value创建对应关系传进了init self.school_course
- '''展示课程'''
- def show_course(self):
- for course in self.school_course:
- course_obj = self.school_course[course]
- print(course_obj.__dict__) #是否需要添加学校
- print('所在分校:%s\t课程名称:%s\t课程价格:%s\t课程学习计划:%s周'
- %(self.school_addr,course_obj.course_name,course_obj.course_price,course_obj.course_time))
- '''修改课程'''
- def modify_course(self): #可能会继续追加、保留
- for course in self.school_course:
- course_obj = self.school_course[course]
- course_obj.course_name= input('修改课程名称>>>:')
- course_obj.course_price = input('修改课程价格>>>:')
- course_obj.course_time = input('修改课程周期>>>:')
- '''创建教室'''
- def create_classroom(self,class_name,course_obj): #创建classroom、关联课程
- class_obj = Class_room(class_name,course_obj) #创建课程对象
- self.sch_class_room[class_name] = class_obj #根据教室名为key,课程对象为value创建对应关系传进了init self.school_course
- '''展示教室'''
- def show_classroom(self):
- for classroom in self.sch_class_room:
- class_obj = self.sch_class_room[classroom]
- #应该是班级名称、对应课程、对应老师、对应的student、保留
- print('班级名称:%s\t课程:%s'
- % (class_obj.class_name,class_obj.course_obj))
- print(class_obj.__dict__)
- '''修改教室'''
- def modify_course(self): #可能会继续追加、保留
- for classroom in self.sch_class_room:
- class_obj = self.sch_class_room[classroom]
- x = time.strftime("%Y%m%d%H%M%S", time.localtime()) #按照根据时间修改教室省去输入
- class_obj.course_obj = input('请慎重输入课程名称>>>:')
- y = time.strftime("%Y%m%d%H%M%S", time.localtime())
- class_obj.class_name= (y+"_"+ class_obj.course_obj)
- '''创建教师'''
- def create_teacher(self,teacher_name,teacher_age,teacher_gender,teacher_salary,class_name,class_obj):
- teacher_obj = Teacher(teacher_name,teacher_age,teacher_gender,teacher_salary)
- teacher_obj.add_tech_classroom(class_name,class_obj) #讲师关联教室
- self.sch_teacher[teacher_name] = teacher_obj
- '''查看教师'''
- def show_teacher(self):
- for teacher_name in self.teacher:
- teacher_obj=self.teacher[teacher_name]
- print('老师姓名:%s','老师年龄:%s','老师性别:%s','老师工资:%s'
- %(teacher_obj.teacher_name,teacher_obj.teacher_age,teacher_obj.teacher_gender,teacher_obj.teacher_salary))
- '''修改老师'''
- def modify_teacher(self):
- for teacher_name in self.teacher:
- teacher_obj=self.teacher[teacher_name]
- teacher_obj.teacher_name = input('请输入修改的老师姓名>>>:')
- teacher_obj.teacher_age = input('请输入修改的老师年龄>>>:')
- teacher_obj.teacher_gender = input('请输入修改的老师性别>>>:')
- teacher_obj.teacher_salary = input('请输入修改的老师工资>>>:')
- '''创建学生'''
- def create_student(self,student_name,student_gender,student_age,student_score,class_name):
- #创建学生对象
- student_obj = Student(student_name,student_gender,student_age,student_score)
- self.sch_student[student_name] = student_obj
- #建立学生和班级的关联关系
- class_obj = self.sch_class_room[class_name]
- class_obj.class_student[student_name] = student_obj
- #更新班级信息
- self.sch_class_room[class_name] =class_obj
class_student.py
- #!/usr/bin/env python
- # -*- coding:utf-8 -*-
- # Author: Colin Yao
- class Student(object):
- def __init__(self,student_name,student_gender,student_age,student_score):
- #学生性命,性别,年龄,分数
- self.student_name = student_name
- self.student_gender = student_gender
- self.student_age = student_age
- self.student_score = student_score
- self.student_classroom = {}
class_teacher.py
- #!/usr/bin/env python
- # -*- coding:utf-8 -*-
- # Author: Colin Yao
- class Teacher(object):
- def __init__(self,teacher_name,teacher_age,teacher_gender
- ,teacher_salary):
- self.teacher_name = teacher_name
- self.teacher_age = teacher_age
- self.teacher_gender = teacher_gender
- self.teacher_salary = teacher_salary
- self.teacher_classroom = {}
- def add_tech_classroom(self,class_name,class_obj):
- self.teacher_classroom[class_name] = class_obj
Python作业选课系统(第六周)的更多相关文章
- Python作业-选课系统
目录 Python作业-选课系统 days6作业-选课系统: 1. 程序说明 2. 思路和程序限制 3. 选课系统程序目录结构 4. 测试帐户说明 5. 程序测试过程 title: Python作业- ...
- python编辑选课系统
一.需求分析 1. 创建北京.上海 2 所学校 2. 创建linux , python , go 3个课程 , linux\py 在北京开, go 在上海开 3. 课程包含,周期,价格,通过学校创建课 ...
- Day7作业:选课系统
这周的作业有点糙,迁就看吧,给大家点思路: readme: 需要安装模块: prettytable 测试帐号: 1.后台管理:admin/admin 只设定了这个后台管理帐号,没有写到数据库中 2.学 ...
- python之选课系统详解[功能未完善]
作业需求 思路:1.先写出大体的类,比如学校类,学生类,课程类-- 2.写出类里面大概的方法,比如学校类里面有创建讲师.创建班级-- 3.根据下面写出大致的代码,并实现其功能 遇到的困 ...
- python作业ATM(第五周)
作业需求: 额度 15000或自定义. 实现购物商城,买东西加入 购物车,调用信用卡接口结账. 可以提现,手续费5%. 支持多账户登录. 支持账户间转账. 记录每月日常消费流水. 提供还款接口. AT ...
- [ python ] 面向对象 - 选课系统
根据源程序进行改写: 原程序地址:http://www.cnblogs.com/lianzhilei/p/5985333.html 如有侵权立即删除. 感谢原作者将完整的代码提供参考. ...
- Python 28 选课系统的讲解
1.首先我们要对每一个新的项目有一个明确的思路,脑子是好东西,但是好记性不如烂笔头,所以,要把能想到的都写下来 2.然后就是创建项目的整体结构框架,比如说:conf ( 配置文件 ) .core ( ...
- python作业堡垒机(第十三周)
作业需求: 1. 所有的用户操作日志要保留在数据库中 2. 每个用户登录堡垒机后,只需要选择具体要访问的设置,就连接上了,不需要再输入目标机器的访问密码 3. 允许用户对不同的目标设备有不同的访问权限 ...
- python作业三级菜单day1(第一周)
一.作业需求: 1. 运行程序输出第一级菜单 2. 选择一级菜单某项,输出二级菜单,同理输出三级菜单 3. 菜单数据保存在文件中 4. 让用户选择是否要退出 5. 有返回上一级菜单的功能 二三级菜单文 ...
随机推荐
- 解决java图形界面label中文乱码
第一:在你的具有main函数的类也即你应用运行的主类上点击右键,选择Run As中的Run Configurations,如下图:java,awt,中文方框,中文乱码第二,在Arguments标签下的 ...
- vue-cli3使用cdn方式引入moment.js
1. index.html引入: <script src="https://cdn.bootcss.com/moment.js/2.20.1/moment.min.js"&g ...
- Django之contenttypes的应用
Django contenttypes 应用 简介 contenttypes 是Django内置的一个应用,可以追踪项目中所有app和model的对应关系,并记录在ContentType表中. 每当我 ...
- dat.gui 上手
dat.gui是款神器产品.一个调试利器.但是用起来很简单很简单 1:引用dat.gui.js. 2:实例化 this.gui = new dat.GUI(); 3:创建可设置一个数据对象.例如v ...
- javascript之彻底理解valueOf, toString
参与运算的都是简单类型(一般就字符串和数字), 复杂类型是不参与运算的. ***当对象(非简单类型)用作键时,会先调用toString()方法把对象转化成字符串 var a = {}, b = ...
- 整合SSM框架应用
普通方式 新建spring模块时引入如下内容: 启用devtools插件(热部署插件) idea需要做如下配置 settings-build-compiler->勾选build project ...
- 【bzoj2600】[Ioi2011]ricehub 双指针法
题目描述 给出数轴上坐标从小到大的 $R$ 个点,坐标范围在 $1\sim L$ 之间.选出一段连续的点,满足:存在一个点,使得所有选出的点到其距离和不超过 $B$ .求最多能够选出多少点. $R\l ...
- 【bzoj2402】陶陶的难题II 分数规划+树链剖分+线段树+STL-vector+凸包+二分
题目描述 输入 第一行包含一个正整数N,表示树中结点的个数.第二行包含N个正实数,第i个数表示xi (1<=xi<=10^5).第三行包含N个正实数,第i个数表示yi (1<=yi& ...
- [AT2363] [agc012_c] Tautonym Puzzle
题目链接 AtCoder:https://agc012.contest.atcoder.jp/tasks/agc012_c 洛谷:https://www.luogu.org/problemnew/sh ...
- Linux内核分析第六周学习笔记——分析Linux内核创建一个新进程的过程
Linux内核分析第六周学习笔记--分析Linux内核创建一个新进程的过程 zl + <Linux内核分析>MOOC课程http://mooc.study.163.com/course/U ...