教师课程管理系统(c++课程设计源代码)
#include
#include
#include
#include
#include
#include
using namespace std;
using std::string;
class ke;
ostream&operator<<(ostream&dist,ke&k);
istream&operator>>(istream&sour,ke&k);
class teacher;
ostream&operator<<(ostream&dist,teacher&t);
istream&operator>>(istream&sour,teacher&t);
class ke
{
protected:
static int keID;
string keName;
char keJB;
int keXS;
int keJC;
int keBH;
public:
ke(string name="未命名的课程",char jb='0',int xs=0,int jc=0,int bh=0);
void show();
friend ostream&operator<<(ostream&dist,ke&k);
friend istream&operator>>(istream&sour,ke&k);
int getkeJC(){return keJC;}
string getkeName(){return keName;}
};
int ke::keID=0;
ke::ke(string name,char jb,int xs,int jc,int bh)
{
keID++;
bh=keID;
keName=name;
keJB=jb;
keXS=xs;
keJC=jc;
keBH=bh;
}
void ke::show()
{
cout<<"课程编号:"< cout<<"课程名称:"< cout<<"课程级别:"; switch (keJB) { case '1':cout<<"公共基础课"< case '2':cout<<"专业基础课"< case '3':cout<<"专业课"< case '4':cout<<"公选课"< } cout<<"学时:"< cout<<"基本课酬:"< } ostream&operator<<(ostream&dist,ke&k) { dist< dist< dist< return dist; } istream&operator>>(istream&sour,ke&k) { sour>>k.keBH>>k.keName>>k.keJB>>k.keXS>>k.keJC; return sour; } class keDB:public ke { public: int judge(); void add(); void del(); }; void keDB::add() { cout<<"请输入课程名称:"; cin>>keName; cout<<"1)公共基础课2)专业基础课3)专业课4)公选课"< cout<<"请输入课程级别(序号):"; cin>>keJB; while(keJB!='1'&&keJB!='2'&&keJB!='3'&&keJB!='4') { cout<<"错了!让你输1、2、3、4你还输别的,专业点好不好=_=...."< cout<<"1)公共基础课2)专业基础课3)专业课4)公选课"< cout<<"请重新输入课程级别(序号):"; cin>>keJB; } cout<<"请输入学时:"; cin>>keXS; while(keXS<=0||keXS>=100) { cout<<"要么学时太多超出范围,要么你就输入了什么奇怪的东西,重新输!"< cout<<"请重新输入学时:"; cin>>keXS; } cout<<"请输入基本课酬:"; cin>>keJC; while(keJC<=0||keJC>=100000) { if(keJC>=10000) cout<<"这个价位也太高了吧,你确定不是在洗黑钱?"< else if(keJC<=0) cout<<"给人上课还倒贴钱,脑子进水了吧=_="< cout<<"请重新输入基本课酬:"; cin>>keJC; } cout<<"课程编号(自动生成):"< } void keDB::del() { keName="未命名的课程"; keJB='0'; keXS=0; keJC=0; } int keDB::judge() { return keJB; } class teacher { protected: static int teachID; string teName; int teNo; string teClass; int teNumber; double teMoney; string kName; keDB k[100]; public: teacher(string kname="none",int no=0,string name="none",string tclass="none",int number=0,int money=0) { teachID++; kName=kname; teNo=teachID; teName=name; teClass=tclass; teNumber=number; teMoney=money; } string getkeName(){return teName;} friend ostream&operator<<(ostream&dist,teacher&t); friend istream&operator>>(istream&sour,teacher&t); void show() { if(teName!="none") { pay(); cout<<"教师编号:"< cout<<"教师姓名:"< cout<<"课程名称:"< cout<<"教授班级编号:"< cout<<"教授班级数量:"< cout<<"课酬:"< } else cout<<"该老师不存在!"< } void pay() { keDB k[100]; int i=0,n=0,m=0; ifstream ifile("D:\\课程数据.data"); for(i=0;i<100;i++) ifile>>k[i]; ifile.close(); for(i=0;i<100;i++) { if(k[i].getkeName()==kName) { m=i; break; } } switch(k[m].judge()) { case '1':if(teNumber<=3) teMoney=k[m].getkeJC()*teNumber; else { if(teNumber<=6) teMoney=k[m].getkeJC()*teNumber*1.1; else teMoney=k[m].getkeJC()*teNumber*1.2; } break; case '2':teMoney=k[m].getkeJC()*1.2*teNumber;break; case '3':teMoney=k[m].getkeJC()*1.2*teNumber;break; case '4':teMoney=k[m].getkeJC()*teNumber;break; } } }; int teacher::teachID=0; ostream&operator<<(ostream&dist,teacher&t) { dist< dist< dist< return dist; } istream&operator>>(istream&sour,teacher&t) { sour>>t.teNo>>t.teName>>t.kName>>t.teClass>>t.teNumber>>t.teMoney; return sour; } class teacherDB:public teacher { public: int judge() { return teNumber; } void add() { int i=0; string temp,a="、"; cout<<"请输入教师名称:"; cin>>teName; cout<<"请输入老师所教授课程的名称"; cin>>kName; cout<<"请输入教师所教授班级的数量"; cin>>teNumber; teClass=""; cout<<"请输入教师所教授班级的编号"; for(i=0;i { cin>>temp; teClass+=temp; teClass+=a; } cout<<"教师编号(自动生成):"< pay(); cout<<"教师课酬(自动生成):"< } void del() { teName="none"; kName="none"; teClass="none"; teNumber=0; teMoney=0; } }; int main() { int i,c; char a,b='1',d,e; string str; keDB k[100]; teacherDB t[100]; cout<<" ╔@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@╗"< cout<<" @@ "< cout<<" @C++ 真难@ "< cout<<" @@ "< cout<<" @(→_→)(←_←)@ "< cout<<" @@ "< cout<<" @(——)@ "< cout<<" @@"< cout<<" @ ▂▃▄▅▅▅▅▄▃▂@ "< cout<<" ╚@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@╝"< cout<<" 按任意键继续。。。"; getch(); system("cls"); cout<<" ********************************||||||||"< cout<<" |||||||||*******************************"< getch(); system("cls"); cout<<" 是否录入过课程数据?(Y/N)"; cin>>a; if(a=='n'||a=='N') { ofstream ofile("D:\\课程数据.data"); for(i=0;i<100;i++) ofile< ofile.close(); } else { ifstream ifile("D:\\课程数据.data"); for(i=0;i<100;i++) ifile>>k[i]; ifile.close(); } cout<<" 是否录入过教师数据?(Y/N)"; cin>>a; if(a=='n'||a=='N') { ofstream ofile1("D:\\教师数据.data"); for(i=0;i<100;i++) ofile1< ofile1.close(); } else { ifstream ifile1("D:\\教师数据.data"); for(i=0;i<100;i++) ifile1>>t[i]; ifile1.close(); } system("cls"); //完成数据初始化。 while(b!='0') { cout<<" ********************************||||||||"< cout<<" * *||||||"< cout<<" * 1) 添加信息*||||"< cout<<" * 2) 删除信息*||"< cout<<" * 3) 修改信息*"< cout<<" * 4) 显示信息*"< cout<<" ||* *"< cout<<" ||||* 0) 退出系统并全部保存*"< cout<<" ||||||* *"< cout<<" ||||||||********************************"< cout<<" 在此处选择操作:"; cin>>b; system("cls"); if(b=='1') { d='1'; while(d!='0') { cout<<" ********************************||||||||"< cout<<" ***** *||||||"< cout<<" *** 1) 添加课程信息*||||"< cout<<" * *||"< cout<<" * 2) 添加教师信息*"< cout<<" * *"< cout<<" ||* 0) 返回*"< cout<<" ||||* ***"< cout<<" ||||||* *****"< cout<<" ||||||||********************************"< cout<<" 在此处选择操作:"; cin>>d; if(d=='1') { for(i=0;i<100;i++) { if(k[i].judge()=='0') { k[i].add(); ofstream ofile("D:\\课程数据.data"); for(i=0;i<100;i++) ofile< ofile.close(); cout<<"添加成功!"< break; } } getch(); system("cls"); continue; } if(d=='2') { for(i=0;i<100;i++) { if(t[i].judge()==0) { t[i].add(); ofstream ofile1("D:\\教师数据.data"); for(i=0;i<100;i++) ofile1< ofile1.close(); cout<<"添加成功!"< break; } } getch(); system("cls"); continue; } if(d=='0') { system("cls"); break; } else { cout<<"MD让你输120你还输别的,搞毛线啊!重来!"< getch(); system("cls"); continue; } } continue; } d='1'; if(b=='2') { while(d!='0') { cout<<" ********************************||||||||"< cout<<" ***** *||||||"< cout<<" *** 1) 删除课程信息*||||"< cout<<" * *||"< cout<<" * 2) 删除教师信息*"< cout<<" * *"< cout<<" ||* 0) 返回*"< cout<<" ||||* ***"< cout<<" ||||||* *****"< cout<<" ||||||||********************************"< cout<<" 在此处选择操作:"; cin>>d; if(d=='1') { for(i=0;i<100;i++) { if(k[i].judge()!='0') {k[i].show();cout< } cout<<" 请选择要删的课程编号:"; cin>>c; if(k[c-1].judge()!='0') { k[c-1].del(); ofstream ofile("D:\\课程数据.data"); for(i=0;i<100;i++) ofile< ofile.close(); cout<<"删除成功!"< } else cout<<"这课早就删了,删了又删,删了还删,你不无聊我都觉得无聊=_="< getch(); system("cls"); continue; } if(d=='2') { for(i=0;i<100;i++) { if(t[i].getkeName()!="none") {t[i].show();cout< } cout<<" 请选择要删的教师编号:"; cin>>c; t[c-1].del(); ofstream ofile1("D:\\教师数据.data"); for(i=0;i<100;i++) ofile1< ofile1.close(); cout<<"删除成功!"< getch(); system("cls"); continue; } if(d=='0') { system("cls"); break; } else { cout<<" MD让你输120你还输别的,搞毛线啊!重来!"< getch(); system("cls"); continue; } } continue; } d='1'; if(b=='3') { while(d!='0') { cout<<" ********************************||||||||"< cout<<" ***** *||||||"< cout<<" *** 1) 修改课程信息*||||"< cout<<" * *||"< cout<<" * 2) 修改教师信息*"< cout<<" * *"< cout<<" ||* 0) 返回*"< cout<<" ||||* ***"< cout<<" ||||||* *****"< cout<<" ||||||||********************************"< cout<<" 在此处选择操作:"; cin>>d; if(d=='1') { for(i=0;i<100;i++) { if(k[i].judge()!='0') {k[i].show();cout< } cout<<" 请选择要修改的课程编号:"; cin>>c; k[c-1].add(); ofstream ofile("D:\\课程数据.data"); for(i=0;i<100;i++) ofile< ofile.close(); cout<<"修改成功!"< getch(); system("cls"); continue; } if(d=='2') { for(i=0;i<100;i++) { if(t[i].getkeName()!="none") {t[i].show();cout< cout<<" 请选择要修改的教师编号:"; cin>>c; if(t[c-1].getkeName()!="none") { t[c-1].add(); ofstream ofile1("D:\\教师数据.data"); for(i=0;i<100;i++) ofile1< ofile1.close(); cout<<"修改成功!"< } else cout<<"该教师并不存在,既然不存在为什么要改呢?"< getch(); system("cls"); continue; } if(d=='0') { system("cls"); break; } else { cout<<" MD让你输120你还输别的,搞毛线啊!重来!"< getch(); system("cls"); continue; } } continue; } d='1'; if(b=='4') { while(d!='0') { cout<<" ********************************||||||||"< cout<<" ***** *||||||"< cout<<" *** 1) 显示课程信息*||||"< cout<<" * *||"< cout<<" * 2) 显示教师信息*"< cout<<" * *"< cout<<" ||* 0) 返回*"< cout<<" ||||* ***"< cout<<" ||||||* *****"< cout<<" ||||||||********************************"< cout<<" 在此处选择操作:"; cin>>d; if(d=='1') { cout<<" 1)按编号查询2)按课程名查询请输入:"; cin>>e; if(e=='1') { cout<<" 请选择要显示的课程编号:"; cin>>c; if(k[c-1].judge()!='0') k[c-1].show(); else cout<<"该课程不存在!"; } else if(e=='2') { bool B=0; cout<<" 请输入课程名:"; cin>>str; for(i=0;i<100;i++) { if(k[i].getkeName()==str) {k[i].show();B=1;} } if(B==0) cout<<" 该课程不存在!"< } else cout<<"唉。。。让你输1和2你都不会,算了算了,不让你重新输了,咱们直接过。"< getch(); system("cls"); continue; } if(d=='2') { cout<<" 1)按编号查询2)按教师名查询请输入:"; cin>>e; if(e=='1') { cout<<" 请选择要显示的教师编号:"; cin>>c; if(t[c-1].judge()!=0) t[c-1].show(); else cout<<"该教师不存在!"; } else if(e=='2') { bool B=0; cout<<" 请输入教师名:"; cin>>str; for(i=0;i<100;i++) { if(t[i].getkeName()==str) {t[i].show();B=1;} } if(B==0) cout<<" 该教师不存在!"< } else cout<<"唉。。。让你输1和2你都不会,算了算了,不让你重新输了,咱们直接过。"< getch(); system("cls"); continue; } if(d=='0') { system("cls"); break; } else { cout<<" MD让你输120你还输别的,搞毛线啊!重来!"< getch(); system("cls"); continue; } } continue; } d='1'; if(b=='0') break; else { cout<<" MD让你输12340你还输别的,搞毛线啊!重来!"< getch(); system("cls"); continue; } } ofstream ofile("D:\\课程数据.data"); for(i=0;i<100;i++) ofile< ofile.close(); ofstream ofile1("D:\\教师数据.data"); for(i=0;i<100;i++) ofile1< ofile1.close(); cout<<" 保存成功!"; system("cls"); cout< cout<<" ▅▅▅▅▅▅▅▅▅▅▅▅▅"<