教师课程管理系统c++课程设计源代码.docx
《教师课程管理系统c++课程设计源代码.docx》由会员分享,可在线阅读,更多相关《教师课程管理系统c++课程设计源代码.docx(26页珍藏版)》请在冰豆网上搜索。
![教师课程管理系统c++课程设计源代码.docx](https://file1.bdocx.com/fileroot1/2023-7/20/8ea53cf5-4e78-48f0-870d-b49ac91b0d79/8ea53cf5-4e78-48f0-870d-b49ac91b0d791.gif)
教师课程管理系统c++课程设计源代码
#include
#include
#include
#include
#include
#include
usingnamespacestd;
usingstd:
:
string;
classke;
ostream&operator<<(ostream&dist,ke&k);
istream&operator>>(istream&sour,ke&k);
classteacher;
ostream&operator<<(ostream&dist,teacher&t);
istream&operator>>(istream&sour,teacher&t);
classke
{
protected:
staticintkeID;
stringkeName;
charkeJB;
intkeXS;
intkeJC;
intkeBH;
public:
ke(stringname="未命名的课程",charjb='0',intxs=0,intjc=0,intbh=0);
voidshow();
friendostream&operator<<(ostream&dist,ke&k);
friendistream&operator>>(istream&sour,ke&k);
intgetkeJC(){returnkeJC;}
stringgetkeName(){returnkeName;}
};
intke:
:
keID=0;
ke:
:
ke(stringname,charjb,intxs,intjc,intbh)
{
keID++;
bh=keID;
keName=name;
keJB=jb;
keXS=xs;
keJC=jc;
keBH=bh;
}
voidke:
:
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<returndist;
}
istream&operator>>(istream&sour,ke&k)
{
sour>>k.keBH>>k.keName>>k.keJB>>k.keXS>>k.keJC;
returnsour;
}
classkeDB:
publicke
{
public:
intjudge();
voidadd();
voiddel();
};
voidkeDB:
:
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<<"这个价位也太高了吧,你确定不是在洗黑钱?
"<elseif(keJC<=0)cout<<"给人上课还倒贴钱,脑子进水了吧=_="<cout<<"请重新输入基本课酬:
";
cin>>keJC;
}
cout<<"课程编号(自动生成):
"<}
voidkeDB:
:
del()
{
keName="未命名的课程";
keJB='0';
keXS=0;
keJC=0;
}
intkeDB:
:
judge()
{
returnkeJB;
}
classteacher
{
protected:
staticintteachID;
stringteName;
intteNo;
stringteClass;
intteNumber;
doubleteMoney;
stringkName;
keDBk[100];
public:
teacher(stringkname="none",intno=0,stringname="none",stringtclass="none",intnumber=0,intmoney=0)
{
teachID++;
kName=kname;
teNo=teachID;
teName=name;
teClass=tclass;
teNumber=number;
teMoney=money;
}
stringgetkeName(){returnteName;}
friendostream&operator<<(ostream&dist,teacher&t);
friendistream&operator>>(istream&sour,teacher&t);
voidshow()
{
if(teName!
="none")
{
pay();
cout<<"教师编号:
"<cout<<"教师姓名:
"<cout<<"课程名称:
"<cout<<"教授班级编号:
"<cout<<"教授班级数量:
"<cout<<"课酬:
"<}
elsecout<<"该老师不存在!
"<}
voidpay()
{
keDBk[100];
inti=0,n=0,m=0;
ifstreamifile("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;
elseteMoney=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;
}
}
};
intteacher:
:
teachID=0;
ostream&operator<<(ostream&dist,teacher&t)
{
dist<dist<dist<returndist;
}
istream&operator>>(istream&sour,teacher&t)
{
sour>>t.teNo>>t.teName>>t.kName>>t.teClass>>t.teNumber>>t.teMoney;
returnsour;
}
classteacherDB:
publicteacher
{
public:
intjudge()
{
returnteNumber;
}
voidadd()
{
inti=0;
stringtemp,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<<"教师课酬(自动生成):
"<}
voiddel()
{
teName="none";
kName="none";
teClass="none";
teNumber=0;
teMoney=0;
}
};
intmain()
{
inti,c;
chara,b='1',d,e;
stringstr;
keDBk[100];
teacherDBt[100];
cout<<"╔@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@╗"<cout<<"@ @"<cout<<"@ C ++ 真 难@"<cout<<"@ @"<cout<<"@ (→_→) (←_←)@"<cout<<"@ @"<cout<<"@ (——) @"<cout<<"@ @"<cout<<"@▂▃▄ ▅▅ ▅▅ ▄▃▂@"<cout<<"╚@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@╝"<cout<<"按任意键继续。
。
。
";
getch();
system("cls");
cout<<"********************************||||||||"<cout<<"**||||||"<cout<<"*课程管理系统(最终版)*||||"<cout<<"*机械科学与工程学院*||"<cout<<"*机制xxxx班*"<cout<<"*组长:
翟南*"<cout<<"||*组员:
一路顺风、kucubfdietiy、鸩羽千夜*"<cout<<"||||*指导老师:
学会闲*"<cout<<"|||||||**"<cout<<"|||||||||*******************************"<cout<<"按任意键继续。
。
。
"<getch();
system("cls");
cout<<"是否录入过课程数据?
(Y/N)";
cin>>a;
if(a=='n'||a=='N')
{
ofstreamofile("D:
\\课程数据.data");
for(i=0;i<100;i++)ofile<ofile.close();
}
else
{
ifstreamifile("D:
\\课程数据.data");
for(i=0;i<100;i++)ifile>>k[i];
ifile.close();
}
cout<<"是否录入过教师数据?
(Y/N)";
cin>>a;
if(a=='n'||a=='N')
{
ofstreamofile1("D:
\\教师数据.data");
for(i=0;i<100;i++)ofile1<ofile1.close();
}
else
{
ifstreamifile1("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();
ofstreamofile("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();
ofstreamofile1("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();
ofstreamofile("D:
\\课程数据.data");
for(i=0;i<100;i++)ofile<ofile.close();
cout<<"删除成功!
"<}
elsecout<<"这课早就删了,删了又删,删了还删,你不无聊我都觉得无聊=_="<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();
ofstreamofile1("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<<"********************