C++学校人员信息管理系统附加代码

C++学校人员信息管理系统附加代码

ID:6681966

大小:734.49 KB

页数:25页

发布时间:2023-01-02 10:51:53

C++学校人员信息管理系统附加代码_第1页
C++学校人员信息管理系统附加代码_第2页
C++学校人员信息管理系统附加代码_第3页
C++学校人员信息管理系统附加代码_第4页
C++学校人员信息管理系统附加代码_第5页
资源描述:

3.学校人员信息管理系统3.1系统概述设计一个学校人员信息管理系统,可以实现对学校人事的信息管理,并且具备以下功能:➢1-增加一位人员(教师、学生)记录➢2-删除一个人员记录➢3-修改一个人员记录➢4-根据“学号(教工号)”、“姓名”、“性别”查找记录➢5-根据人员类别(学生、教师)查找“English”课程成绩最高的学生,或最高工资的教师➢6-显示全部人员记录➢7-从外部文件追加数据➢8-将所有数据保存到磁盘文件➢9-退出系统。3.2系统框架结构和算法思想框架结构:①:构造三个类(People,Student,Teacher),将People类设为基类,Student类与Teacher类为People的派生类;②:在类中创建人员的基本信息的数据成员,以及对数据进行处理的功能函数;③:将功能函数定义为派生类的友元函数,并且在两个派生类中分别重载“<<”与“>>”运算符,在类外说明功能函数,并且创建一个容器,用于存储派生类student的数据成员;③:在主函数中,创建选择菜单,运用循环,来选择想要实现的功能。算法思想:①:为两个派生类teacher与student,设置静态数据成员,并且为其赋初值;②:功能函数中:形参中为派生类student的静态数据成员与结构指针,或者是派生类teacher的静态数据成员与结构指针。在基类中为虚函数,在派生类中为友元函数。③:插入数据函数:通过传静态数据成员与结构指针,用于输入一个老师或者学生的信息,并将他们保存在容器中(为学生设置了容器,老师没有)④:删除数据函数:通过传静态数据成员与结构指针,以及老师或者学生的职工号,用于判定,是否存在想要删除的职工号。运用for循环,将想要删除的老师或学生的信息删除,即通过将该指针后一个位置的指针赋值给它,然后之后的指针全部往前移一位。⑤:修改数据函数:通过传静态数据成员与结构指针,以及老师或者学生的职工号,用于判定,是否存在想要删除的职工号。如果是,则修改学生的数学、英语、语文的成绩或者老师工资、职称信息。,⑥:查找数据函数:通过传静态数据成员与结构指针,分三种情况查询(学号、姓名、性别),通过循环,当输入的查询情况与存储中的情况符合的话,则输出该学生或者老师的全部信息,否则,则输出查无此人。⑦:显示信息函数:通过传静态数据成员与结构指针,先判断静态数据成员是否为0;为0则显示无数据;反之则用for循环输出全体学生或者老师的信息。⑧:从外部追加数据函数:两个派生类分别各种构建新的成员函数,派生类student则打开“Student_ext.dat”文件,在while中运用getline函数将文件中的数据读取到数组a中,然后输出读取信息。派生类teacher则打开“Teacher_ext.dat”文件,在while中运用getline函数将文件中的数据读取到数组a中,然后输出读取信息。⑧:存储信息函数:将输入的数据存在输出文件“Student.dat”中,运用for循环将全部添加的数据存入,然后关闭文件,提示数据已经录入。⑨:用容器输出存储的学生数据函数:输入想要查询的学生班级,然后运用for循环,找到对应的数据,然后将容器中存储的对呀信息输出。⑩:输出英语成绩最好的学生信息或者工资最高的老师信息:在主函数中判断出,英语成绩最高的学生或者工资最高的老师,然后运用隐指针输出该学生或者老师的信息。〇:退出系统函数输出学生数据3.3功能模块实现修改学生数据按学号查询删除学生数据查找学生数据按姓名查询学生按性别查询输出英语成绩最高的学生信息显示所有学生的全部信息从外部文件读取数据将学生数据存储在文件中利用容器输出学生数据学校人员信息管理系统退出系统,输出老师数据输出学生数据修改老师数据输出学生数据查找老师数据输出学生数据输出工资最高的老师的信息老师显示所有老师的信息从外部文件读取数据将老师数据存储在文件中删除老师信息退出系统,3.4系统测试,,,,,3.5系统设计总结通过对学校人员管理系统的编写,我初步认识了解了容器的创建、输入数据、输出数据的运用,对于系统功能结构的掌控也更加熟练;并且对c++基类、派生类、友元函数、虚函数、静态数据成员的使用与创建也有了更加深刻地理解,能够更加熟练地运用c++类的知识。进一步了解到了c++文件的打开、存储、读取、关闭的使;能够熟练地使用清屏函数system(“cls”)与暂停一会函数system(“pause”),运用于系统菜单的刷新与美观;并且能够合理地选择、控制数据成员的数据类,以及懂得如何在类中运用函数模板。代码如下:#include#include#include//文件的写入#include#include//等价于c语言#include//通过控制台进行数据的输入输出函数#include//格式化输出(可不用)#include#include//容器#include////清屏的代码usingnamespacestd;,intTeacher_Count=0;intStudent_Count=0;voidPrintf(){system("color09");//用于背景颜色system("cls");//清屏cout<<"

1*********欢迎使用高校人员信息管理系统*********"<voidFindMaxData(Tcount);//在类中运用函数模板friendvoidDisplay(intstu,student*p);friendvoidmess();friendvoidrongqi();friendistream&operator>>(istream&in,student&p){in>>p.Student_number;in>>p.Name;in>>p.Sex;in>>p.Age;returnin;};friendostream&operator<<(ostream&out,student&p){out<searches[100];//定义容器classteacher:virtualpublicpeople{public:intTeacher_number,Teacher_EducationYear;doubleTeacher_salary;stringTeacher_department,Teacher_major;friendvoidAddData(intcout,teacher*p);friendvoidDeleteData(intk,intcount,teacher*p);,friendvoidUpdateData(intk,intcount,teacher*p);friendvoidSearchData(teacher*p,intcount);voidFindMaxData();friendvoidDisplay(inttea,teacher*p);friendvoidmess1();friendistream&operator>>(istream&in,teacher&p){in>>p.Teacher_number;in>>p.Name;in>>p.Sex;in>>p.Age;};friendostream&operator<<(ostream&out,teacher&p){out<>h;for(autoiterator:searches[h]){cout<<"名字:"<>c;switch(c){case7:cout<<"请输入教工号"<>nu;for(intd=0;dTeacher_number){flag5=0;cout<<"姓名:"<Name<<"性别:"<Sex<<"年龄:"<Age<<"岁"<<"出生日期:"<Birth<<"教工号:"<Teacher_number<<"教龄:"<Teacher_EducationYear<<"年"<<"工作系别部门:"<Teacher_major<<"职称"<Teacher_department<<"工资:"<Teacher_salary<<"元";}}if(flag5){cout<<"查无此人";}getchar();break;case8:cout<<"请输入姓名"<>a;for(intd=0;dName){flag6=0;cout<<"姓名:"<Name<<"性别:"<Sex<<"年龄:"<Age<<"岁"<<"出生日期:"<Birth<<"教工号:"<Teacher_number<<"教龄:"<Teacher_EducationYear<<"年"<<"工作系别部门:"<Teacher_major<<"职称"<Teacher_department<<"工资:"<Teacher_salary<<"元";}}if(flag6){cout<<"查无此人";}getchar();break;case9:cout<<"请输入性别"<>b;for(intd=0;dSex){flag7=0;cout<<"姓名:"<Name<<"性别:"<Sex<<"年龄:"<Age<<"岁"<<"出生日期:"<Birth<<"教工号:"<Teacher_number<<"教,龄:"<Teacher_EducationYear<<"年"<<"工作系别部门:"<Teacher_major<<"职称"<Teacher_department<<"工资:"<Teacher_salary<<"元";}}if(flag7){cout<<"查无此人";}getchar();break;default:cout<<"错误"<>c;switch(c){case7:cout<<"请输入学号"<>nu;for(intd=0;dStudent_number){flag=0;cout<<"姓名:"<Name<<"性别:"<Sex<<"年龄:"<Age<<"岁"<<"出生日期:"<Birth<<"学号:"<Student_number<<"专业:"<Student_major<<"班级:"<cla<<"班"<<"语文:"<Chinese<<"分"<<"英语:"<English<<"分"<<"数学:"<Mathmatics<<"分"<<"身份:"<Student_identity;}}if(flag){cout<<"查无此人";};break;case8:cout<<"请输入姓名"<>a;,for(intd=0;dName){flag1=0;cout<<"姓名:"<Name<<"性别:"<Sex<<"年龄:"<Age<<"岁"<<"出生日期:"<Birth<<"学号:"<Student_number<<"专业:"<Student_major<<"班级:"<cla<<"班"<<"语文:"<Chinese<<"分"<<"英语:"<English<<"分"<<"数学:"<Mathmatics<<"分"<<"身份:"<Student_identity;}}if(flag1){cout<<"查无此人";};break;case9:cout<<"请输入性别"<>b;for(intd=0;dSex){flag2=0;cout<<"姓名:"<Name<<"性别:"<Sex<<"年龄:"<Age<<"岁"<<"出生日期:"<Birth<<"学号:"<Student_number<<"专业:"<Student_major<<"班级:"<cla<<"班"<<"语文:"<Chinese<<"分"<<"英语:"<English<<"分"<<"数学:"<Mathmatics<<"分"<<"身份:"<Student_identity;}}if(flag2){cout<<"查无此人";};break;default:cout<<"错误"<Name<<"性别:"<Sex<<"年龄:"<Age<<"岁"<<"出生日期:"<Birth<<"职工号:"<Teacher_number<<"教龄:"<Teacher_EducationYear<<"年"<<"工作系别部门:"<Teacher_major<<"职称:"<Teacher_department<<"工资:"<Teacher_salary<<"元"<Name<<"性别:"<Sex<<"年龄:"<Age<<"岁"<<"出生日期:"<Birth<<"学号:"<Student_number<<"专业:"<Student_major<<"班级:"<cla<<"班"<<"语文:"<Chinese<<"分"<<"英语:"<English<<"分"<<"数学:"<Mathmatics<<"分"<<"身份:"<Student_identity<Student_number==k){k1=1;cout<<"请输入数学,语文,英语成绩"<>p->Mathmatics;cin>>p->Chinese;cin>>p->English;}}if(k1!=1){cout<<"puterror"<Teacher_number==k){k2=1;cout<<"请输入职称和工资"<>p->Teacher_department;cin>>p->Teacher_salary;}}if(k2!=1){cout<<"puterror"<Student_number){ss1=1;for(h;hName=(p+1)->Name;p->Sex=(p+1)->Sex;p->Birth=(p+1)->Birth;p->Age=(p+1)->Age;p->Chinese=(p+1)->Chinese;p->English=(p+1)->English;p->Mathmatics=(p+1)->Mathmatics;p->Student_number=(p+1)->Student_number;p->cla=(p+1)->cla;p->Student_identity=(p+1)->Student_identity;p->Student_major=(p+1)->Student_major;}}if(ss1==0){cout<<"输入学号不匹配"<Teacher_number){intss=1;for(h;hName=(p+1)->Name;p->Sex=(p+1)->Sex;p->Birth=(p+1)->Birth;p->Age=(p+1)->Age;p->Teacher_number=(p+1)->Teacher_number;p->Teacher_major=(p+1)->Teacher_major;p->Teacher_department=(p+1)->Teacher_department;p->Teacher_salary=(p+1)->Teacher_salary;p->Teacher_EducationYear=(p+1)->Teacher_EducationYear;,}}if(ss==0){cout<<"输入教工号不匹配";}else{cout<<"删除成功!"<>use->Name>>use->Age>>use->Sex>>use->Birth>>use->Student_number>>use->Student_major>>use->cla>>use->Chinese>>use->Mathmatics>>use->English>>use->Student_identity;if(use->cla<0){cout<<"输入的班级为负数,请重新输入"<>use->Name>>use->Age>>use->Sex>>use->Birth>>use->Student_number>>use->Student_major>>use->cla>>use->Chinese>>use->Mathmatics>>use->English>>use->Student_identity;}intnum=use->cla;searches[num].push_back(*(use));}//插入信息学生部分voidAddData(intcount,teacher*p){teacher*use;use=p+count;cout<<"姓名,年龄,性别,出生日期,教工号,教学时间,工资,工作系别,专业"<>use->Name>>use->Age>>use->Sex>>use->Birth>>use->Teacher_number>>use->Teacher_EducationYear>>use->Teacher_salary>>use->Teacher_department>>use->Teacher_major;try{if(use->Teacher_salary<0)throwuse->Teacher_salary;}catch(double){cout<<"教工的工资为负数,请重新输入"<Teacher_salary<0),{cout<<"请重新输入教工的工资:"<>use->Teacher_salary;}}//插入教工信息(并且进行异常处理)voidteacher::FindMaxData(){teacher*l;l=this;cout<<"工资最高的老师"<Name<<""<Sex<Age<<"岁"<Birth<<""<Teacher_number<<""<Teacher_EducationYear<<"年"<Teacher_major<<""<Teacher_department<Teacher_salary<<"元";}template//在类中中运用函数模板voidstudent::FindMaxData(Tcount){student*l;l=this;cout<<"名字为:"<Name<<""<<"性别为:"<Sex<<""<<"年龄为:"<Age<<"岁"<<"出生为:"<Birth<<""<<"学号为:"<Student_number<<""<<"学生专业为:"<Student_major<<""<cla<<"班"<<"语文为:"<Chinese<<"分"<<"语文为:"<English<<"分"<<"数学为:"<Mathmatics<<"分"<<"学生身份为;"<Student_identity;}voidmess(student*p){ofstreamout("Student.dat",ios::out);//存入输出文件for(inti=0;iStudent_number<<"";out<Name<<"";out<Sex<<"";out<Age<<"";out<Student_major<<"";out<cla<<"";out<Student_identity<<"";out<Chinese<<"";out<Mathmatics<<"";out<English<<"";}out.close();cout<<"学生信息已经读入Student.dat中"<Teacher_number<<"";out<Name<<"";out<Sex<<"";out<Age<<"";out<Teacher_major<<"";out<Teacher_department<<"";out<Teacher_EducationYear<<"";out<Teacher_salary<<"";}out.close();cout<<"教职工信息已经读入Teacher.dat中"<>test;switch(test){case1:cout<<"想添加学生的信息请输入a,想添加老师的信息请输入b"<>pink;if(pink=='a'){AddData(Student_Count,p);Student_Count++;cout<<"已经完成了一条数据的添加"<>pink1;if(pink1=='c'){cout<<"请输入你要删除的学生的学号"<>k;,DeleteData(k,Student_Count,p);Student_Count=Student_Count-1;p=a;getchar();system("pause");system("cls");}if(pink1=='d'){cout<<"请输入你要删除的老师的教工号"<>k;DeleteData(k,Teacher_Count,h);Teacher_Count=Teacher_Count-1;h=b;getchar();system("pause");system("cls");}break;case3:cout<<"如果你想要修改学生的成绩请输入e,如果你想修改老师的工资请输入f"<>pink2;if(pink2=='e'){cout<<"请输入你要修改的学生的学号"<>k1;UpdateData(k1,Student_Count,p);p=a;getchar();system("pause");system("cls");}if(pink2=='f'){cout<<"请输入你要修改老师的教工号"<>k1;UpdateData(k1,Teacher_Count,h);h=b;getchar();system("pause");system("cls");},break;case4:cout<<"如果你想要寻找学生的请输入g,如果你想修改老师的工资请输入h"<>pink3;if(pink3=='g'){SearchData(p,Student_Count);system("pause");p=a;}if(pink3=='h'){SearchData(h,Teacher_Count);system("pause");h=b;}break;case5:cout<<"如果你想要寻找学生请输入j,如果你想寻找老师输入k"<>pink4;if(pink4=='j'){intk=0;student*m;m=p;for(k;kEnglish>(p+1)->English){}else{m=p+1;}}if(Student_Count!=0){m->FindMaxData(Student_Count);}else{cout<<"没有数据";}p=a;getchar();getchar();}if(pink4=='k'){teacher*l;intk=0;h=b;l=b;for(k;kTeacher_salary>(h+1)->Teacher_salary){,}else{l=h+1;}}if(Teacher_Count!=0){l->FindMaxData();}else{cout<<"没有数据";}h=b;getchar();getchar();}break;case6:Display(Student_Count,p);cout<

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1、本文档共25页,下载后即可获取全部内容。
2、此文档《C++学校人员信息管理系统附加代码》由用户(槐*秋起)提供并上传付费之前 请先通过免费阅读内容等途径辨别内容,本站所有文档下载所得的收益全部归上传人(卖家)所有:如有侵权或不适当内容,请进行举报或申诉。
3、所有的PPT和DOC文档都被视为“模板”允许上传人保留音节日灵结构的情况下删减部份的内容,下裁前须认直查看,确认无误后再购买。
4、万象文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护外理,无法对各卖家所售文档的直实性,完整性,准确性以及专业性等问题提供审核和保证,请谨慎购买。
5、本站文档的总页数,文档格式和文档大小以系统显示为准(内容中显示页数不一定正确),网站客服只以系统显示页数,文件格式,文档大小作为仲裁依据。