//#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;
}
Logo

快速构建 Web 应用程序

更多推荐