c++人员管理系统【类】

//#include"Employee.h"
#include<iostream>
#include<cmath>
#include<string>
#include<windows.h>
using namespace std;
int laker=1;
class date
{
private:
int year;
int month;
int day;
    public:
    date(){}
    date(int y,int m,int d):year(y),month(m),day(d){}
        int setYear(int Year){year=Year;}
int setMonth(int Month){month=Month;}
int setDay(int Day){day=Day;}
        int GetYear(){return year;}
        int GetMonth(){return month;}
        int GetDay(){return day;}
};
class Employee
{
private:
string ID,name,postion;
int fee;
date birth;
string sex;
public:
Employee(){}
void get(string id,string Name,string Sex,int year,int month,int day,string Postion);
virtual void display()=0;
virtual void pay()=0;
void change(string n){postion=n;}
string getid(){return ID;}
string getname(){return name;}
void birthtime(){cout<<"出生年月: "<<birth.GetYear()<<"/"<<birth.GetMonth()<<"/"<<birth.GetDay()<<"  ";} 
string getsex(){return sex;}
string getpostion(){return postion;}
void showfee();
virtual void promote()=0;
virtual void cc(string m)=0;
};
void Employee::get(string id,string Name,string Sex,int year,int month,int day,string Postion)
{
birth.setYear(year);
birth.setMonth(month);
birth.setDay(day);
ID=id;
name=Name;
postion=Postion;
sex=Sex;
}
class manager:public Employee

public:
manager(){}
void pay(){cout<<"月薪为:¥8000"<<endl;}
void display()
{
cout<<"编号: "<<this->getid()<<"  ";
cout<<"姓名: "<<this->getname()<<" ";
cout<<"性别: "<<this->getsex()<<endl;
this->birthtime();
cout<<"职位: "<<this->getpostion()<<"  "<<endl; 

void promote(){this->change("CEO");}
void cc(string m)
{
if(this->getname()==m)
{
this->promote();
laker=0;
}
}
};
class technician:virtual public Employee
{
private:
int worktime;
public:
technician(){}
void setworktime(int w){worktime=w;}
void showwork(){cout<<"worktime: "<<worktime<<"小时"<<endl;}
void display()
{
cout<<"编号: "<<this->getid()<<"  ";
cout<<"姓名: "<<this->getname()<<" ";
cout<<"性别: "<<this->getsex()<<endl;
this->birthtime();
cout<<"职位: "<<this->getpostion()<<"  "; 
cout<<"工作时间: "<<worktime<<endl;

void pay(){cout<<"月薪为: ¥"<<worktime*25<<endl;}
void promote(){this->change("技术主管");}
void cc(string m)
{
if(this->getname()==m)
{
this->promote();
laker=0;
}
}
};
class saleman:public Employee
{
private:
float salenum;
string belongs;
public:
saleman(){}
void setsalenum(float sale){salenum=sale;}
void setbelongs(string be){belongs=be;}
void pay(){cout<<"月薪为: ¥"<<salenum*0.04<<endl;}
void promote(){this->change("销售经理");}
void display()
{
cout<<"编号: "<<this->getid()<<"  ";
cout<<"姓名: "<<this->getname()<<" ";
cout<<this->getsex()<<endl;
this->birthtime();
cout<<"职位: "<<this->getpostion()<<"  "; 
cout<<"所属地区: "<<belongs<<" "<<endl; 
}
void cc(string m)
{
if(this->getname()==m)
{
this->promote();
laker=0;
}
}
};
int main()
{
cout<<"Boss,请输入你要录入的人员信息个数:";
int n,num=0;
cin>>n; 
cout<<"人员信息录入:【请依次输入ID,姓名,性别,出生年月,职位。】 "<<endl; 
string ID,name,postion,sex;
int year,month,day;
Employee *EM[n];
manager a[n];
saleman b[n];
technician c[n];
for(int i=0;i<n;i++)
{
cout<<i+1<<"号:";
cin>>ID>>name>>sex>>year>>month>>day>>postion;
if(postion=="总经理")
{
// manager a;
EM[num]=&a[i];
a[i].get(ID,name,sex,year,month,day,postion);
// a[i].display();
// a[i].pay();
}
else if(postion=="推销员")
{
// saleman b;
EM[num]=&b[i];
float w;
string be;
cout<<"请输入所属地区: ";
cin>>be;
cout<<"  请输入销售额: "; 
cin>>w;
cout<<"请继续输入其他人员信息:"<<endl;
b[i].get(ID,name,sex,year,month,day,postion);
b[i].setsalenum(w);
b[i].setbelongs(be);
// b.display();
// b.pay();
}
else if(postion=="技术人员")
{
// technician a;
EM[num]=&c[i];
int workt;
cout<<"请输入该技术人员每月工作时间【单位:小时】: ";
cin>>workt; 
cout<<"请继续输入其他人员信息:"<<endl; 
c[i].get(ID,name,sex,year,month,day,postion);
c[i].setworktime(workt);
// c[i].display();
// c[i].pay();
}
num++;
}
cout<<"如果输入结束,请输入#号键。" <<endl;
char logo;
cin>>logo;
cout<<"人员信息输出:"<<endl; 
for(int k=0;k<n;k++)
{
EM[k]->display();
EM[k]->pay();
}
cout<<"Boss,你是否要为你的员工升职【Yes or No】"<<endl;
string jud;
cin>>jud;
if(jud=="Yes")
{
cout<<"Boss,请问你要为谁升职?"<<endl;
string find;
cin>>find;
for(int k=0;k<n;k++)
{
EM[k]->cc(find);
if(laker==0)
{
cout<<"Ok,sir。你的意愿已经执行,升职后的员工信息为:"<<endl;
EM[k]->promote();
EM[k]->display();
break;
}
else continue;
}
}
Sleep(5000);
cout<<"系统结束。"<<endl;
return 0;
}
  • 3
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
【员工管理系统】 问题描述:每个员工的信息包括:编号、姓名、性别、出生年月、学历、职务、电话、住址等。系统能够完成员工信息的查询、更新、插入、删除、排序等功能。 基本要求:排序:按不同关键字,对所有员工的信息进行排序;查询:按特定条件查找员工;更新,按编号对某个员工的某项信息进行修改;插入,加入新员工的信息;删除,按编号删除已离职的员工的信息。 选作内容:实现图形用户界面。 通过链表实现 数据结构: #include #include #include #include #include using namespace std; typedef struct workers{ char name[15];//姓名 char department[18];//单位 char gender;//性别 unsigned int age;//年龄 unsigned long long telephone;//电话 unsigned long wage;//工资 unsigned long num;//职工号 struct workers *next; }*Linklist,Lnode; void frist_print() { printf("\t\t⊙▽⊙ ⊙▽⊙ ⊙▽⊙ ⊙▽⊙ ⊙▽⊙ ⊙▽⊙ \n\n"); printf("\t\t\t欢迎进入员工管理系统\n"); } void menu() { printf("\n\t\t^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); printf("\t\t \t ◎1.创建员工信息\t \n"); printf("\t\t \t ◎2.插入员工信息\t \n"); printf("\t\t \t ◎3.修改员工信息\t \n"); printf("\t\t \t ◎4.删除员工信息\t \n"); printf("\t\t \t ◎5.查询员工信息\t \n"); printf("\t\t \t ◎6.员工信息排序\t \n"); printf("\t\t \t ◎7.显示员工信息\t \n"); printf("\t\t \t ◎8.员工工资情况\t \n"); printf("\n\t\t^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); printf("注意:输入均以回车作为结束\n"); printf("please choise 1--8:\t "); //putchar(12); } void Inset(Linklist Head){ Linklist s,L; unsigned int agee; unsigned long wagee,numm;
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值