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
| #include<bits/stdc++.h> #include"student.h" #include"Report.h"
using namespace std;
int menu(){ int temp; cout<<endl; cout<<"-----------------------学生绩点系统-----------------------"<<endl; cout<<"----------------------------------------------------------"<<endl; cout<<"----"<<setw(20)<<"输入 1: 输入学号并删除相应记录 "<<endl; cout<<"----"<<setw(20)<<"输入 2: 删除所有学生的记录 "<<endl; cout<<"----"<<setw(20)<<"输入 3: 分类别显示所有学生绩点记录表 "<<endl; cout<<"----"<<setw(20)<<"输入 4: 输入类别并显示该类别学生绩点记录表 "<<endl; cout<<"----"<<setw(20)<<"输入 5: 输入学生信息插入至学生绩点记录表 "<<endl; cout<<"----"<<setw(20)<<"输入-1: 退出 "<<endl; cout<<"----------------------------------------------------------"<<endl; cin>>temp; return temp; } Report *init(){ Report *temp=new Report; try{
(*temp).insert((student*)new CStudent(101,"李博"s,"男"s,21,"CStudent"s,95,91,80)); (*temp).insert((student*)new CStudent(102,"李欣"s,"女"s,20,"CStudent"s,100,100,99)); (*temp).insert((student*)new CStudent(103,"李蓉"s,"女"s,20,"CStudent"s,100,99,99)); (*temp).insert((student*)new CStudent(104,"黄黄"s,"男"s,21,"CStudent"s,80,99,60)); (*temp).insert((student*)new FStudent(1001,"EaKal"s,"男"s,21,"FStudent"s,80,99,60)); (*temp).insert((student*)new FStudent(1002,"Rolemee"s,"男"s,20,"FStudent"s,90,99,70)); (*temp).insert((student*)new FStudent(1003,"Bazingaa"s,"女"s,18,"FStudent"s,95,99,90)); (*temp).insert((student*)new FStudent(1004,"Elagal"s,"男"s,23,"FStudent"s,80,99,60)); } catch(const char* msg){ cout<<msg<<endl; }
return temp; } int main(){ Report *stu=init(); while(1){ switch (menu()) { case 1: int sno; cout<<"请输入您要删除的学号"<<endl; cin>>sno; try{stu->delete_once(sno);} catch(const char* msg){ cout<<msg<<endl; } break; case 2: stu->delete_all(); cout<<"删除所有记录成功!"<<endl; break; case 3: try{ stu->print("CStudent"); stu->print("FStudent"); } catch(const char* msg){ cout<<msg<<endl; } break; case 4: try{ string Select; cout<<"请输入你想要输出的类别"<<endl; cin>>Select; if(Select=="本科生"s){ Select="CStudent"s; }else if(Select=="留学生"s){ Select="FStudent"s; } stu->print(Select); } catch(const char* msg){ cout<<msg<<endl; } break; case -1: exit(0); default: break; } } return 0; }
|