c++课程设计高校工资管理系统.docx

上传人:b****4 文档编号:11711182 上传时间:2023-03-30 格式:DOCX 页数:20 大小:157.74KB
下载 相关 举报
c++课程设计高校工资管理系统.docx_第1页
第1页 / 共20页
c++课程设计高校工资管理系统.docx_第2页
第2页 / 共20页
c++课程设计高校工资管理系统.docx_第3页
第3页 / 共20页
c++课程设计高校工资管理系统.docx_第4页
第4页 / 共20页
c++课程设计高校工资管理系统.docx_第5页
第5页 / 共20页
点击查看更多>>
下载资源
资源描述

c++课程设计高校工资管理系统.docx

《c++课程设计高校工资管理系统.docx》由会员分享,可在线阅读,更多相关《c++课程设计高校工资管理系统.docx(20页珍藏版)》请在冰豆网上搜索。

c++课程设计高校工资管理系统.docx

c++课程设计高校工资管理系统

C++课程设计

1.系统概述

通过设计一个较为简单的《高校工资管理系统》,进一步熟悉C++中类的概念、类的封装、继承的实现方式。

了解系统开发的需求分析、类层次设计、模块分析、编码测试、模块组装与整体调试的全过程,加深对C++的理解与VisualC+瑯境的使用;逐步熟悉程序设计的方法,并养成良好的编程习惯。

2.总体设计

2.1职工类的设计

基于C++中类的概念,类的封装,继承和抽象。

编写一个Person的基类包含共有的相

关信息和操作,然后使职工类都继承于此基类从而实现多态。

2.2应用类的设计

编写一个Person类的友元类College类来实现添加,删除,查找等功能。

2.3文件的读写设计

通过College类中的Save()函数来实现数据的存储,保存在Person.dat中,而通过Load()函数来实现Person.dat数据的读入。

3.详细设计及系统实现

3.1

Person

virtual

void

Input()=0;

//从键盘输入数据

virtual

void

Input(ifstream&ifs)=0;

//

从文件输入数据

virtual

void

Output()=0;

//

向屏幕输出数据

virtual

void

Output(ofstream&ofs)=0;

//

向文件输出数据

virtual

doubleIncoming()=0;

//

计算收入

friend

class

College;

};

3.2Teacher

classTeacher:

{

protected:

intHours;

public:

virtualpublicPerson

//教师课时

//教师类

 

//为对象设置数据分为两种途径,通过)构造函数,)一般成员函数

//分开可以使得程序中应用更加灵活

//本程序采用:

缺省构造+Input()

//构造函数,初始化部分数据

Teacher()

{

'0';

Duty=Salary=800;

}

//键盘补充输入其它数据

voidInput()

{

"编号:

";cin>>No;

"姓名:

";cin>>Name;

"教师上学期课时:

";cin>>Hours;

cout<<

cout<<

cout<<}

voidInput(ifstream&ifs)

{ifs>>No>>Name>>Duty>>Hours;

}

voidOutput()

{

cout<

"<<"\t\t"<

}

voidOutput(ofstream&ofs)

{

ofs<

doubleIncoming()

{

returnSalary+(Hours-120)*20;

}};

3.3Assistant类

classAssistant:

virtualpublicPerson//实验员{

protected:

intAllowance;

intHours;public:

Assistant()

{

Duty='1';

Salary=650;

Allowance=150;

}

voidInput()

{

cout<<

cout<<

cout<<

}

"编号:

";cin>>No;

"姓名:

";cin>>Name;

"实验员上学期实验课时:

";cin>>Hours;

voidInput(ifstream&ifs)

{

ifs>>No>>Name>>Duty>>Hours;

}

voidOutput()

{

cout<

\t\t"<

}

voidOutput(ofstream&ofs)

{

ofs<

}

doubleIncoming()

{

returnSalary+Allowance+(Hours-70)*20;

}

};

3.4Manager类

classManager:

virtualpublicPerson//行政人员{

protected:

intAllowance;public:

Manager()

{

Duty='2';Salary=750;Allowance=250;

}

voidInput()

{

cout<<"编号:

";cin>>No;

cout<<"姓名:

";cin>>Name;

}

voidInput(ifstream&ifs){

ifs>>No>>Name>>Duty;

}

voidOutput()

{

cout<

voidOutput(ofstream&ofs)

{

ofs<

}

doubleIncoming()

{

returnSalary+Allowance;

}

};

3.5Teacher_Assistant类

classTeacher_Assistant:

publicTeacher,publicAssistant//教师兼实验员{

public:

Teacher_Assistant()

{

Duty='3';

Teacher:

:

Salary=800;

}

voidInput()

{

cout<<"编号:

";cin>>No;

cout<<"姓名:

";cin>>Name;

cout<<"教师上学期课时:

";cin>>Teacher:

:

Hours;

cout<<"教师兼职实验员上学期实验课时:

";cin>>Assistant:

:

Hours;

}

voidInput(ifstream&ifs)

{ifs>>No>>Name>>Duty>>Teacher:

:

Hours>>Assistant:

:

Hours;

}

voidOutput()

{

cout<

:

Hours<<""<

:

Hours<<"\t"<

}

voidOutput(ofstream&ofs)

{

ofs<

:

Hours<<""<

:

Hours<

}

doubleIncoming()

{

returnSalary+(Teacher:

:

Hours-120)*20+Allowance+(Assistant:

:

Hours-70)*20;

}

};

3.6Manager_Teacher类

classManager_Teacher:

publicManager,publicTeacher//行政人员兼教师{

public:

Manager_Teacher()

{

Duty='4';Manager:

:

Salary=750;

}

voidInput()

{

"编号:

";cin>>No;

"姓名:

";cin>>Name;

"行政人员兼职教师上学期课时:

";cin>>Hours;

cout<<

cout<<

cout<<

}

voidInput(ifstream&ifs)

{ifs>>No>>Name>>Duty>>Hours;

}

voidOutput()

{

cout<

"<

}

voidOutput(ofstream&ofs)

{

ofs<

}

doubleIncoming()

{

returnSalary+Allowance+Hours*20;

}

};

3.7College类

3.7.1

College:

:

College(){

Person*p=newTeacher;

PL=p;

cout<<"自动装入数据...\n";Load();

}

头文件

intCollege:

:

Find(

intID,Person**p1,Person**p2);

public:

College();

//构造

~College();

//析构

voidAdd();

//增加职工

voidDelete();

//删除职工

voidModify();

//修改职工

voidPrint();

//输出职工信息

voidSave();

//职工信息存盘

voidLoad();

//职工信息装入

voidFinding();};

//查找职工

J>

3.7.2构造函数

//构造函数(创建个头结点的链表)

classCollege

{private:

Person*PL;voidClear();

3.7.3析构函数

College:

:

~College()//析构函数(仅保留个头结点){

Person*p=PL;

while(p)//逐个删除结点,包括头结点

{

PL=p->next;deletep;

p=PL;

}

PL=0;}

3.7.4Add函数

voidCollege:

:

Add()//增加职工

{

高校工资管理系统*******************\n\n\n"

增加职工,输入x结束**\n\n";

cout<<"\t\t*******cout<<"\n\t\t\t\t**

//查找尾结点

Person*p=PL;

while(p->next)p=p->next;

charch='m';

//创建新结点,录入数据,连接到链表Teacher*pt;Assistant*pa;Manager*pm;

Teacher_Assistant*pta;Manager_Teacher*pmt;

cout<<"职工分类码[0-教师,1-实验员,2-行政人员,3-教师兼实验员,4-行政兼教师]:

\n\n";

for(;ch!

='x';)

{

cout<<"类别:

";cin>>ch;

switch(ch){

case'0':

pt=newTeacher;pt->Input();p->next=pt;

break;

case'1':

pa=newAssistant;pa->Input();p->next=pa;

break;

case'2':

pm=newManager;pm->Input();p->next=pm;

break;

case'3':

pta=newTeacher_Assistant;pta->Input();p->next=pta;

break;

case'4':

pmt=newManager_Teacher;pmt->Input();p->next=pmt;

break;

}p=p->next;

}}

3.7.5Find函数

//查找职工结点(返回-找到,-未找到.结点指针由p1返回,p2为前看指针)

intCollege:

:

Find(intID,Person**p1,Person**p2)

{

*p1=PL->next;

*p2=PL;

while(*p1)

{

if((*p1)->No==ID)

break;//找到

else

{

*p2=*p1;//继续查找

*p1=(*p1)->next;

}

}

return*p1?

1:

0;

}

3.7.6Clear函数

voidCollege:

:

Clear()//清除所有的职工结点(仅保留头结点){

Person*p=PL->next;while(p)

{

PL->next=p->next;deletep;

p=PL->next;

}

}

3.7.7Delete函数

//删除职工

voidCollege:

:

Delete()

高校工资管理系统*******************\n\n\n"删除职工**\n";

{

cout<<"\t\t*******

cout<<"\n\t\t\t\t**intNo;

Person*p1,*p2;

cout<<"编号:

";cin>>No;

if(!

Find(No,&p1,&p2))

{

cout<<"指定的人员没有找到!

\n";

}

else

{

//连接

p2->next=p1->next;

deletep1;

cout<<"正确删除!

\n";}

}

3.7.8

Modify函数

3.7.9

Print函数

"\t\t****************高校工资管理系统*******************\n\n\n""\n**职工信息表**\n\n";

"编号\t姓名\t岗位\t\t其它\t工资\n";

Person*p=PL->next;

if(!

p)

{

cout<<"无职工记录!

\n";

return;

}

while(p)//遍历链表,输出职工信息

{p->Output();p=p->next;

}

}

voidCollege:

:

Save()

{

ofstreamf("Person.dat",ios:

:

out);

//遍历输出至文件

Person*p=PL->next;

while(p)

{p->Output(f);p=p->next;

}

f.close();//关闭文件

cout<<"职工信息已经保存在Person.dat.\n";}voidCollege:

:

Load()

{

charbuf[81];

charDuty;

Person*p2;

//职工信息存盘

//职工信息装入

//临时空间

//人员类型

//新建结点的指针

longt;//读写位置

//清除现有结点(保留头结点)

Clear();

//打开文件

ifstreamf("Person.dat",ios:

:

in);

//建立结点,读数据

Person*p=PL;//尾结点指针while

(1)

{

//读取人员类型t=f.tellg();f>>buf>>buf>>Duty;

if

{

(f)

//根据人员类型创建新结点switch(Duty)

case

case

case

casecase

'0'

'1'

'2'

'3'

'4'

p2=

p2=

p2=

p2=p2=

default:

f.close();

//打开文件

newTeacher;newAssistant;newManager;newTeacher_Assistant;break;newManager_Teacher;break;

return;

break;

break;

break;

 

p->next=p2;p=p->next;f.seekg(t);p->Input(f);

}

else

break;

}

关闭文件

//

f.close();

高校工资管理系统*******************\n\n\n"查找职工**\n";

cout<<"Person.dat数据已装入.\n";}voidCollege:

:

Finding(){

cout<<"\t\t*******cout<<"\n\t\t\t\t**

Person*p1,*p2;intID;

coutvv"编号;";

cin>>ID;

coutvv"\n\n";

p1=PL->next;p2=PL;

while(p1)

{

if((p1)->No==ID)

{

coutvv"编号\t姓名\t岗位\t\t其它\t工资\n";(p1)->Output();

break;

}//找到

else

{

p2=p1;//继续查找

p1=(p1)->next;

}

}

}

3.8界面函数

charMeau(){

charc;intflag;

do

{

system("cls");flag=1;

cout<<"\t\t****

*\n\n\n""\t\t\t"\t\t\t"\t\t\t"\t\t\t

cout<<

cout<<

cout<<

cout<

cout<<"\t\t\t

cout<<"\t\t\tcout<<"\t\t\tcout<<"\t\t\tcout<<"\t\t\tcout<<"\t\t\t

1

1

11

1

、增加职工

12

、删除职工

3

、查找职工丨

14

、修改职工

15

、输出职工信息

6

、数据存盘丨

7

、数据装入丨

8

1

、退出丨

1

高校工资管理系统

\n";

\n";

\n";

\n";

\n";

\n";

\n";

\n";

\n";

\n";

\n";

cout<<"\n\n\n\t\t请输入您的选择:

cin>>c;

if(c=='1'||c=='2'||c=='3'||c=='4'||c==flag=0;

}while(flag);returnc;

}//显示主菜单,

'5'||c=='6'

||c=='7'||c=='8')

接受选择

 

3.9主函数

voidmain()

{

charch;

//定义大学对象

Collegec;

do{

ch=Meau();

switch(ch){

case'1':

system("cls");c.Add();cout<<

"\n\n\t\t

按任意键结

束...\n";getchar();getchar();break;

case'2':

system("cls");c.Delete();cout<<束...\n";getchar();getchar();break;

"\n\n\t\t

按任意键结

case'3':

system("cls");c.Finding();cout<<束...\n";getchar();getchar();break;

"\n\n\t\t

按任意键结

case'4':

system("cls");c.Modify();cout<<束...\n";getchar();getchar();break;

"\n\n\t\t

按任意键结

case'5':

system("cls");c.Print();cout<<束...\n";getchar();getchar();break;

"\n\n\t\t

按任意键结

5.1主界面

实现各种功能的选择:

5.2

添加功能

6.设计体会与建议

6.1体会

通过这次对《高校工资管理系统》这个实验的设计,充分感受并体会到了C++中的

面对对象设计的真意,以及学习了对一个程序的分解和分工完成的方法,掌握了一点编写的技巧。

实际的操作与解决问题的能力更有了大幅的提升。

6.2建议

希望在以后的课程设计中,能更多的得到老师的帮助,可以帮助我们更清晰地理清思路,以及一些编程上的技巧。

7.附录

7.1成员

7.2分工

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 人文社科 > 法律资料

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1