资源描述
高职学院
C++程序设计语言上学期
课 程 设 计 报 告
( -第1学期)
课程设计类型:C语言程序设计
题目:人员信息管理系统
学号:
姓名:
专业:计算机应用基础
指导老师:
课程设计日期:.12.23-.12.27.
目 录
1. 问题分析 1
2. 总体设计 1
2.1 功效分析 1
3. 具体设计 2
3.1 程序结构图 2
3.2 程序类结构图 2
3.3 程序类结构图 3
4. 功效测试 4
4.1 本系统主界面 4
4.2 录入功效主界面 4
4.3 显示功效主界面 5
4.4 查找功效主界面 5
4.5 修改功效主界面 6
4.6 删除功效主界面 6
4.7 清理功效主界面 7
4.8 退出功效主界面 7
5. 课设小结 7
参 考 文 献 8
附录:源代码清单 8
1. 问题分析
1.1 问题描述
1.题目《人员信息管理系统》设计
2.设计说明和要求
(1) 企业关键有4类人员:经理、技术人员、销售员、销售经理,要求存放这些人姓名、年纪、工资信息。
(2) 工资计算方法
A、 经理:固定为8000元;
B、 技术员:工作时间*每小时酬金(100RMB);
C、 销售员:4%分成;
D、 销售经理:1%分成+固定工资(5000RMB);
(3) 实现功效
① 录入:输入多种数据,并录入TXT文件保留;
② 显示:显示职员数据信息;
③ 查找:查找职员数据信息;
④ 修改:修改职员数据信息;
⑤ 删除:删除职员数据信息;
⑥ 退出:退出本系统;
⑦ 清理存放文件:清理系统产生TXT文件;
2. 总体设计
2.1 功效分析
使用面向对象程序设计思想进行分析,整个系统包含两大类信息和操作,企业,人员。所以系统关键包含两个大类:企业类business、人员类person。系统总体框架就是企业类,人员类定义;主函数中定义一个企业对象,循环显示主菜单并依据用户选择调用企业类对应方法(组员函数)。
3. 具体设计
3.1 程序结构图
雇员类
技术员类
经理类
销售员类类
销售经理类
3.2 程序类结构图
Person类
char name[20];
char post[20];
char hour[20];
int age;
int number;
void in;
void pay;
void out;
Sell类
int phpay;
int monthpay;;
void in;
void pay;
void out;
Technician类
int hourlyRate;
int workHours;
void in;
void pay;
void out;
Business类
int time;
void in;
void pay;
void out;
Sell类
int phpay;
int monthpay;
void in;
void pay;
void out;
Bagman类
int phpay;
void in;
void pay;
void out;
3.3 程序类结构图
开始
输入选择
Switch(c)
Case 6
结束
删除职员信息
Case 1
Case 4
Case 2
Case 5
Case 3
Case 0
修改职员信息
查找职员信息
显示职员信息
录入职员信息
删除存放文件
4. 功效测试
4.1 本系统主界面
4.2 录入功效主界面
4.3 显示功效主界面
4.4 查找功效主界面
4.5 修改功效主界面
4.6 删除功效主界面
4.7 清理功效主界面
4.8 退出功效主界面
5. 课设小结
依据课程设计要求,我思索出了自己课题,我用本学期所学C++面向对象知识来编写程序。我利用面向对象方法和C++编程思想来完成系统设计,在设计过程中,建立清楚层次,当然在调试过程中我也碰到了很多问题。
本程序由雇员这个基类派生出多个派生类,而且调用多个函数。主函数关键利用选择结构。派生类中保护类数据要经过定义公有类型函数来从类外调用。和部分相当复杂算法,自己看了全部乱,头全部晕。不过,我相信,不经历风雨怎么能见彩虹。在处理了这一切后,我有一个:天将降大任于斯人也,必先劳其筋骨,饿其体肤感觉!
参 考 文 献
1. 钱能主编,C++程序设计教程,清华大学出版社,.11
2. 戴锋编著,Visual C++程序设计基础,清华大学出版社,.4
3. 施平安主编,C++程序设计教程(第四版),清华大学出版社,.3
4. 林丽闽主编,标准C++程序设计教程,电子工业出版社,.6.1
5. 谭浩强主编,C++程序设计,清华大学出版社,.6
附录:源代码清单
#include<iostream.h>
#include<fstream.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
class person
{
public:
char name[20],post[20],hour[20];
int age,number;
};
class business :public person
{
public :
int time;
}
;
//经理
class mgr : public person
{
public:
int monthpay;
mgr :: mgr()
{
monthpay=8000 ;
}
void out()
{
cout<<"请输入职员编号:";
cin>>number ;
cout<<"请输入职员姓名:";
cin>>name ;
cout<<"请输入职员年纪:";
cin>>age ;
cout<<"该职员月薪为:"<<monthpay<<endl;
}
void in()
{
cout<<"编号:"<<number<<' '<<"姓名:"<<name<<' '<<"年纪:"<<age<<' '<<"职称:"<<"经理 "<<' '<<"月薪:"<<monthpay<<endl;
}
};
//技术人员
class technician :public person
{
public:
int hourlyRate ;
//每小时酬金
int workHours ;
//当月工作时数
int pay;
technician :: technician()
{
hourlyRate=100 ;
};
void in()
{
cout<<"编号:"<<number<<' '<<"姓名:"<<name<<' '<<"年纪:"<<age<<' '<<"职称:"<<"技术人员"<<' '<<"月薪:"<<pay<<endl ;
}
void out()
{
cout<<"请输入职员编号:";
cin>>number ;
cout<<"请输入职员名字:";
cin>>name ;
cout<<"请输入工作小时:";
cin>>workHours ;
cout<<"请输入职员年纪:";
cin>>age ;
pay=hourlyRate*workHours;
cout<<"该职员月薪为:"<<pay<<endl;
}
};
//销售经理
class sell :public business
{
public:
int phpay,monthpay;
sell :: sell()
{
phpay=1,monthpay=5000;
}
void in()
{
cout<<"编号:"<<number<<" "<<"姓名:"<<name<<" "<<"销售额:"<<time<<" "<<"年纪:"<<age<<" "<<"职称:"<<"销售经理"<<" "<<"月薪:"<<pay()<<endl ;
}
int pay()
{
return(phpay*time+monthpay);
}
void out()
{
cout<<"请输入职员编号:";
cin>>number ;
cout<<"请输入职员名字:";
cin>>name ;
cout<<"请输入销售额 :";
cin>>time ;
cout<<"请输入职员年纪:";
cin>>age ;
cout<<"职员月薪为:"<<pay()<<endl;
}
};
//推销员
class bagman :public business
{
public:
int phpay ;
bagman :: bagman()
{
phpay=4;
}
void in()
{
cout<<"编号:"<<number<<" "<<"姓名:"<<name<<" "<<"销售额:"<<time<<" "<<"年纪:"<<age<<" "<<"职称:"<<"推销员 "<<" "<<"年薪:"<<pay()<<endl ;
}
int pay()
{
return(phpay*time);
}
void out()
{
cout<<"请输入职员编号:";
cin>>number ;
cout<<"请输入职员名字:";
cin>>name ;
cout<<"请输入销售额 :";
cin>>time ;
cout<<"请输入职员年纪:";
cin>>age ;
cout<<"该职员月薪为:"<<pay()<<endl;
}
};
//输入函数
void write1()
{
mgr p;
p.out();
ofstream myfile("f1.txt",ios :: binary|ios :: ate);
myfile.write((char*)&p,sizeof p);
myfile.close();
}
void write2()
{
technician p;
p.out();
ofstream myfile("f2.txt",ios :: binary|ios :: ate);
myfile.write((char*)&p,sizeof p);
myfile.close();
}
void write3()
{
sell p;
p.out();
ofstream myfile("f3.txt",ios :: binary|ios :: ate);
myfile.write((char*)&p,sizeof p);
myfile.close();
}
void write4()
{
bagman p;
ofstream myfile("f4.txt",ios :: binary|ios :: ate);
p.out();
myfile.write((char*)&p,sizeof p);
myfile.close();
}
void build()
{
cout<<endl;
cout<<" ******************请选择职员信息****************** "<<endl;
cout<<" ** 1.经理 ** "<<endl;
cout<<" ** 2.技术人员 ** "<<endl;
cout<<" ** 3.销售经理 ** "<<endl;
cout<<" ** 4.推销员 ** "<<endl;
cout<<" **************************************************** "<<endl;
cout<<"请输入选择:"<<endl;
char ch;
cin>>ch;
while(ch!='N'&&ch!='n')
{
switch(ch)
{
case '1' :
write1();
break ;
case '2' :
write2();
break ;
case '3' :
write3();
break ;
case '4' :
write4();
break ;
default :
cout<<"ERROR!!"<<endl;
break ;
}
cout<<"是否继续使用录入功效:(Y/N)?";
cin>>ch;
if(ch=='Y'||ch=='y')
{
cout<<"请输入选择:"<<endl;
cin>>ch;
}
}
}
//显示函数
void show1()
{
ifstream myfile("f1.txt",ios :: binary|ios :: out|ios :: in);
mgr p;
myfile.read((char*)&p,sizeof p);
while(!myfile.eof())
{
p.in();
myfile.read((char*)&p,sizeof p);
}
myfile.close();
}
void show2()
{
ifstream myfile("f2.txt",ios :: binary|ios :: out|ios :: in);
technician p;
myfile.read((char*)&p,sizeof p);
while(!myfile.eof())
{
p.in();
myfile.read((char*)&p,sizeof p);
}
myfile.close();
}
void show3()
{
ifstream myfile("f3.txt",ios :: binary|ios :: out|ios :: in);
sell p ;
myfile.read((char*)&p,sizeof p);
while(!myfile.eof())
{
p.in();
myfile.read((char*)&p,sizeof p);
}
myfile.close();
}
void show4()
{
ifstream myfile("f4.txt",ios :: binary|ios :: out|ios :: in);
bagman p ;
myfile.read((char*)&p,sizeof p);
while(!myfile.eof())
{
p.in();
myfile.read((char*)&p,sizeof p);
}
myfile.close();
}
void show0()
{
show1();
show2();
show3();
show4();
}
void show()
{
cout<<" **********************你正在显示********************"<<endl;
cout<<" ** 0.全部显示 **"<<endl;
cout<<" ** 1.经理 **"<<endl;
cout<<" ** 2.技术人员 **"<<endl;
cout<<" ** 3.销售经理 **"<<endl;
cout<<" ** 4.推销员 **"<<endl;
cout<<" ****************************************************"<<endl;
cout<<"请选择你要显示职员类:"<<endl;
char c;
cin>>c ;
while(c!='N'&&c!='n')
{
switch(c)
{
case '0' :
show0();
break;
case '1' :
show1();
break;
case '2' :
show2();
break;
case '3' :
show3();
break;
case '4' :
show4();
break;
default :
cout<<"ERROR!!"<<endl;
break;
}
cout<<"是否继续使用显示功效(Y/N)?"<<endl;
cin>>c;
if(c=='Y'||c=='y')
{
cout<<"请选择你要显示职员类:"<<endl;
cin>>c;
}
}
}
//查找函数
void search1()
{
int m=1;
cout<<"请输入你要查找编号:"<<endl;
int number;
cin>>number;
ifstream myfile("f1.txt",ios :: binary|ios :: out|ios :: in);
mgr p;
myfile.read((char*)&p,sizeof p);
while(!myfile.eof())
{
if(number==p.number)
{
p.in();
myfile.close();
m=0;
}
myfile.read((char*)&p,sizeof p);
}
if(m)
cout<<"查无此人!!!"<<endl;
}
void search2()
{
int m=1;
cout<<"请输入你要查找编号:"<<endl;
int number;
cin>>number;
ifstream myfile("f2.txt",ios :: binary|ios :: out|ios :: in);
technician p;
myfile.read((char*)&p,sizeof p);
while(!myfile.eof())
{
if(number==p.number)
{
p.in();
myfile.close();
m=0;
}
myfile.read((char*)&p,sizeof p);
}
if(m)
cout<<"查无此人!!!"<<endl;
}
void search3()
{
int m=1;
cout<<"请输入你要查找编号:"<<endl;
int number;
cin>>number;
ifstream myfile("f3.txt",ios :: binary|ios :: out|ios :: in);
sell p ;
myfile.read((char*)&p,sizeof p);
while(!myfile.eof())
{
if(number==p.number)
{
p.in();
myfile.close();
m=0;
}
myfile.read((char*)&p,sizeof p);
}
if(m)
cout<<"查无此人!!!"<<endl;
}
void search4()
{
int m=1;
cout<<"请输入你要查找编号:"<<endl ;
int number;
cin>>number;
ifstream myfile("f4.txt",ios :: binary|ios :: out|ios :: in);
bagman p ;
myfile.read((char*)&p,sizeof p);
while(!myfile.eof())
{
if(number==p.number)
{
p.in();
myfile.close();
m=0;
}
myfile.read((char*)&p,sizeof p);
}
if(m)
cout<<"查无此人!!!"<<endl;
}
void search()
{
cout<<" *********************你正在查找*********************"<<endl;
cout<<" ** 1.经理 **"<<endl;
cout<<" ** 2.技术人员 **"<<endl;
cout<<" ** 3.销售经理 **"<<endl;
cout<<" ** 4.推销员 **"<<endl;
cout<<" ****************************************************"<<endl;
cout<<"请选择你职称类型:"<<endl;
char c;
cin>>c;
while(c!='N'&&c!='n')
{
switch(c)
{
case '1' :
search1();
break;
case '2' :
search2();
break;
case '3' :
search3();
break;
case '4' :
search4();
break;
default :
cout<<"ERROR!!"<<endl;
break;
}
cout<<"是否继续使用查找功效(Y/N)?";
cin>>c;
if(c=='Y'||c=='y')
{
cout<<"请选择你职称类型:"<<endl;
cin>>c;
}
}
}
//修改函数
void repair1(void)
{
int num,i=0,k=0;
mgr*p1=new mgr[50];
cout<<"请输入你要修改编号:";
cin>>num ;
ifstream h1("f1.txt",ios :: binary|ios :: in);
h1.read((char*)&p1[i],sizeof p1[i]);
while(!h1.eof())
{
i++;
h1.read((char*)&p1[i],sizeof p1[i]);
}
h1.close();
k=i ;
for(i=0;i<k;i++)
{
if(num==p1[i].number)
{
p1[i].out();
cout<<"修改完成!"<<endl ;
}
}
ofstream h2("f1.txt",ios :: binary|ios :: out);
for(i=0;i<k;i++)
{
h2.write((char*)&p1[i],sizeof p1[i]);
}
h2.close();
delete[]p1 ;
}
void repair2(void)
{
int num,i=0,k=0;
technician*p2=new technician[50];
cout<<"请输入你要修改编号:";
cin>>num;
ifstream h2("f2.txt",ios :: binary|ios :: in);
h2.read((char*)&p2[i],sizeof p2[i]);
while(!h2.eof())
{
i++;
h2.read((char*)&p2[i],sizeof p2[i]);
}
h2.close();
k=i ;
for(i=0;i<k;i++)
{
if(num==p2[i].number)
{
p2[i].out();
cout<<"修改完成!"<<endl;
}
}
ofstream h1("f2.txt",ios :: binary|ios :: out);
for(i=0;i<k;i++)
{
h1.write((char*)&p2[i],sizeof p2[i]);
}
h1.close();
delete[]p2;
}
void repair3(void)
{
int num,i=0,k=0;
sell*p6=new sell[50];
cout<<"请输入你要修改编号:";
cin>>num ;
fstream h6("f3.txt",ios :: binary|ios :: out|ios :: in);
h6.read((char*)&p6[i],sizeof p6[i]);
while(!h6.eof())
{
i++;
h6.read((char*)&p6[i],sizeof p6[i]);
}
k=i ;
h6.close();
for(i=0;i<k;i++)
{
if(num==p6[i].number)
{
p6[i].in();
cout<<"修改完成!"<<endl;
}
}
ofstream h1("f6.txt",ios :: binary|ios :: out);
for(i=0;i<k;i++)
{
h1.write((char*)&p6[i],sizeof p6[i]);
}
h1.close();
delete[]p6;
}
void repair4(void)
{
int num,i=0,k=0 ;
bagman*p7=new bagman[50];
cout<<"请输入你要修改编号:";
cin>>num;
fstream h7("f4.txt",ios :: binary|ios :: out|ios :: in);
h7.read((char*)&p7[i],sizeof p7[i]);
while(!h7.eof())
{
i++;
h7.read((char*)&p7[i],sizeof p7[i]);
}
k=i;
h7.close();
for(i=0;i<k;i++)
{
if(num==p7[i].number)
{
p7[i].out();
cout<<"修改完成!"<<endl;
}
}
ofstream h1("f7.txt",ios :: binary|ios :: out);
for(i=0;i<k;i++)
{
h1.write((char*)&p7[i],sizeof p7[i]);
}
h1.close();
delete[]p7;
}
void repair()
{
cout<<" *********************你正在修改*********************"<<endl;
cout<<" ** 1.经理 **"<<endl;
cout<<" ** 2.技术人员 **"<<endl;
cout<<" ** 3.销售经理 **"<<endl;
cout<<" ** 4.推销员 **"<<endl;
cout<<" ****************************************************"<<endl;
cout<<"请输入你要修改职称类型:"<<endl ;
char c;
cin>>c;
while(c!='N'&&c!='n')
{
switch(c)
{
case '1' :
repair1();
break;
case '2' :
repair2();
break;
case '3' :
repair3();
break;
case '4' :
repair4();
break;
default :
cout<<"ERROR!!"<<endl;
break;
}
cout<<"是否继续修改(Y/N)?"<<endl;
cin>>c;
if(c=='Y'||c=='y')
{
cout<<"请输入你要修改职称类型:"<<endl;
cin>>c;
}
}
}
void delete1()
{
int i=0,number;
ifstream myfile("f1.txt",ios :: binary|ios :: in);
mgr p[30];
myfile.read((char*)(p+i),sizeof*p);
cout<<"请输入你要删除对象编号:"<<endl;
cin>>number;
while(!myfile.eof())
{
if(number==p[i].number)
{
i--;
}
i++;
myfile.read((char*)(p+i),sizeof*p);
}
int k=i;
myfile.close();
ofstream file2("f1.txt",ios :: binary|ios :: out);
for(i=0;i<k;i++)
{
file2.write((char*)(p+i),sizeof*p);
}
}
void delete2()
{
int i=0,number ;
ifstream myfile("f2.txt",ios :: binary|ios :: in);
technician p[30];
myfile.read((char*)(p+i),sizeof*p);
cout<<"请输入你要删除对象编号:"<<endl ;
cin>>number ;
while(!myfile.eof())
{
if(number==p[i].number)
{
i--;
}
i++;
myfile.read((char*)(p+i),sizeof*p);
}
int k=i;
myfile.close();
ofstream file2("f2.txt",ios :: binary|ios :: out);
for(i=0;i<k;i++)
{
file2.write((char*)(p+i),sizeof*p);
}
}
void delete3()
{
int i=0,number;
ifstream myfile("f3.txt",ios :: binary|ios :: in);
sell p[30];
myfile.read((char*)(p+i),sizeof*p);
展开阅读全文