请你描述一下你的初步思路吧
代码如下:如有帮助,请采纳一下,谢谢。
#include <iostream>
#include <string>
using namespace std;
//员工类
class Employee
{
protected:
string m_name;
string m_sex;
int m_id;
int m_age;
float m_solary;
public:
Employee(int gh,string nm,string sex,int age)
{
m_id = gh;
m_name = nm;
m_sex = sex;
m_age = age;
}
string getName(){return m_name;}
virtual double getSolary() = 0;
virtual void display()
{
cout << m_id << "\t" << m_name << "\t" << m_sex << "\t" << m_age ;
}
};
//文秘
class WenMi:public Employee
{
private:
int jiangjin;
public:
WenMi(int gh,string nm,string sex,int age,int jj):Employee(gh,nm,sex,age)
{
jiangjin = jj;
}
double getSolary()
{
return 4000 + jiangjin;
}
void display()
{
cout << m_id << "\t" << m_name << "\t" << m_sex << "\t" << m_age << "\t" << getSolary() << endl;
}
};
//技术经理
class Jishujingli :public Employee
{
private:
int yeji;
public:
Jishujingli(int gh,string nm,string sex,int age,int yj):Employee(gh,nm,sex,age)
{
yeji = yj;
}
double getSolary()
{
return 5000 + yeji * 1000;
}
void display()
{
cout << m_id << "\t" << m_name << "\t" << m_sex << "\t" << m_age << "\t"<< getSolary() << endl;
}
};
//技术员
class Jishuyuan:public Employee
{
private:
int hour;
public:
Jishuyuan(int gh,string nm,string sex,int age,int h):Employee(gh,nm,sex,age)
{
hour = h;
}
double getSolary()
{
return 40 * hour;
}
void display()
{
cout << m_id << "\t" << m_name << "\t" << m_sex << "\t" << m_age << "\t" << getSolary() << endl;
}
};
//销售员
class Xiaoshouyuan :public Employee
{
private:
int xiaoshouer; //销售额
int suoshujingli; //所属经理(填写经理工号)
public:
Xiaoshouyuan(int gh,string nm,string sex,int age,int xse,int jlgh):Employee(gh,nm,sex,age)
{
xiaoshouer = xse;
suoshujingli = jlgh;
}
int getSuoshujingli(){return suoshujingli;}
int getXse(){return xiaoshouer;}
double getSolary()
{
return xiaoshouer * 0.05;
}
void display()
{
cout << m_id << "\t" << m_name << "\t" << m_sex << "\t" << m_age << "\t" << getSolary() << endl;
}
};
//销售经理
class Xiaoshoujingli : public Employee
{
private:
int m_sxze; //销售总额
public:
Xiaoshoujingli(int gh,string nm,string sex,int age):Employee(gh,nm,sex,age)
{
//m_sxze = ze;
}
void setXsze(int ze){m_sxze = ze;}
double getSsze(){return m_sxze;}
double getSolary()
{
return m_sxze * 0.003 + 5000;
}
void showXsed()
{
cout << m_id << "\t" << m_name << "\t" << m_sex << "\t" << m_age << "\t" << getSsze() <<endl;
}
void display()
{
cout << m_id << "\t" << m_name << "\t" << m_sex << "\t" << m_age << "\t" << getSolary() <<endl;
}
};
//录入信息
void InputInfo(WenMi* wm[],int &nmbwm ,Jishuyuan* jsy[],int &nmbjsy,Jishujingli* jsjl[],int &nmbjsjl,Xiaoshouyuan* xsy[],int &nmbsxy,Xiaoshoujingli* xsjl[],int &nmbxsjl)
{
cout << "请输入文秘的数量:";
cin >> nmbwm;
for (int i = 0; i < nmbwm; i++)
{
int gh,age,jj;string name,sex;
cout << "请输入文秘" << i+1 << "的信息(工号、姓名、性别、年龄、奖金):";
cin >> gh >> name >> sex >> age >> jj;
wm[i] = new WenMi(gh,name,sex,age,jj);
}
cout << "请输入技术员的数量:" ;
cin >> nmbjsy;
for (int i = 0; i < nmbjsy ;i++)
{
int gh,age,hour;string name,sex;
cout << "请输入技术员" << i+1 << "的信息(工号、姓名、性别、年龄、工作时长):";
cin >> gh >> name >> sex >> age >> hour;
jsy[i] = new Jishuyuan(gh,name,sex,age,hour);
}
cout << "请输入技术经理的数量:";
cin >> nmbjsjl;
for (int i = 0; i < nmbjsjl; i++)
{
int gh,age,level;string name,sex;
cout << "请输入技术经理" << i+1 << "的信息(工号、姓名、性别、年龄、等级):";
cin >> gh >> name >> sex >> age >> level;
jsjl[i] = new Jishujingli(gh,name,sex,age,level);
}
cout << "请输入销售员的数量:";
cin >> nmbsxy;
for (int i = 0; i < nmbsxy;i++)
{
int gh,age,ed,id;string name,sex;
cout << "请输入销售员" << i+1 << "的信息(工号、姓名、性别、年龄、销售额、所属经理工号):";
cin >> gh >> name >> sex >> age >> ed >> id;
xsy[i] = new Xiaoshouyuan(gh,name,sex,age,ed,id);
}
cout << "请输入销售经理的数量:";
cin >> nmbxsjl;
for (int i = 0; i< nmbxsjl; i++)
{
int gh,age;string name,sex;
cout << "请输入销售经理" << i+1 << "的信息(工号、姓名、性别、年龄):";
cin >> gh >> name >> sex >> age;
xsjl[i] = new Xiaoshoujingli(gh,name,sex,age);
int zed = 0;
for (int j = 0;j< nmbsxy;j++)
{
if(xsy[j]->getSuoshujingli() == gh)
zed += xsy[j]->getXse();
}
xsjl[i]->setXsze(zed);
}
}
//统计额度
void Tontjied(Xiaoshoujingli* xsjl[],int nmbxsjl)
{
for (int i = 0; i < nmbxsjl -1; i++)
{
for (int j = 0; j < nmbxsjl -1-i; j++)
{
if(xsjl[j]->getSsze() < xsjl[j+1]->getSsze())
{
Xiaoshoujingli* tmp = xsjl[j];
xsjl[j] = xsjl[j+1];
xsjl[j+1] = xsjl[j];
}
}
}
//
for(int i = 0; i < nmbxsjl; i++)
xsjl[i]->showXsed();
}
//显示信息
void ShowAll(WenMi* wm[],int &nmbwm ,Jishuyuan* jsy[],int &nmbjsy,Jishujingli* jsjl[],int &nmbjsjl,Xiaoshouyuan* xsy[],int &nmbsxy,Xiaoshoujingli* xsjl[],int &nmbxsjl)
{
cout << "文秘信息:" << endl;
for (int i = 0;i < nmbwm;i++)
{
wm[i]->display();
}
cout << "技术员信息:" << endl;
for (int i = 0; i < nmbjsy;i++)
{
jsy[i]->display();
}
cout << "技术经理信息:" << endl;
for (int i = 0; i< nmbjsjl;i++)
{
jsjl[i]->display();
}
cout << "销售员信息:" << endl;
for (int i = 0; i < nmbsxy; i++)
{
xsy[i]->display();
}
cout << "销售经理信息:" << endl;
for (int i = 0; i < nmbxsjl;i++)
{
xsjl[i]->display();
}
}
//显示信息
void FindEmp(WenMi* wm[],int &nmbwm ,Jishuyuan* jsy[],int &nmbjsy,Jishujingli* jsjl[],int &nmbjsjl,Xiaoshouyuan* xsy[],int &nmbsxy,Xiaoshoujingli* xsjl[],int &nmbxsjl)
{
string name;
cout << "请输入需要查找的姓名" << endl;
cin >> name;
for (int i = 0;i < nmbwm;i++)
{
if (wm[i]->getName().compare(name) == 0)
{
cout << "文秘信息:" ;
wm[i]->display();
return;
}
}
for (int i = 0; i < nmbjsy;i++)
{
if (jsy[i]->getName().compare(name) == 0)
{
cout << "技术员信息:" ;
jsy[i]->display();
return;
}
}
for (int i = 0; i< nmbjsjl;i++)
{
if (jsjl[i]->getName().compare(name) == 0)
{
cout << "技术经理信息:" ;
jsjl[i]->display();
return;
}
}
for (int i = 0; i < nmbsxy; i++)
{
if (xsy[i]->getName().compare(name) == 0)
{
cout << "销售员信息:" ;
xsy[i]->display();
return;
}
}
for (int i = 0; i < nmbxsjl;i++)
{
if (xsjl[i]->getName().compare(name) == 0)
{
cout << "销售经理信息:" ;
xsjl[i]->display();
return;
}
}
}
int main()
{
bool bwork = true;
int opt = 0; //功能选项
WenMi* wm[10]; //文秘
int nmbwm = 0;
Jishuyuan* jsy[20]; //技术员
int nmbjsy = 0;
Jishujingli* jsjl[10]; //技术经理
int nmbjsjl = 0;
Xiaoshouyuan* xsy[20]; //销售员
int nmbsxy = 0;
Xiaoshoujingli* xsjl[10];//销售经理
int nmbxsjl = 0;
cout << "---------工资管理系统--------" << endl;
cout << "| 1.录入员工信息 |" << endl;
cout << "| 2.统计各销售经理销售额度|" << endl;
cout << "| 3.数据打印 |" << endl;
cout << "| 4.数据查询 |" <<endl;
cout << "| 5.退出系统 |" << endl;
cout << "-----------------------------" << endl;
while(bwork)
{
cin >> opt;
switch(opt)
{
case 1:
InputInfo(wm,nmbwm , jsy,nmbjsy, jsjl,nmbjsjl, xsy,nmbsxy, xsjl,nmbxsjl);
break;;
case 2:
Tontjied(xsjl,nmbxsjl);
break;
case 3:
ShowAll(wm,nmbwm , jsy,nmbjsy, jsjl,nmbjsjl, xsy,nmbsxy, xsjl,nmbxsjl);
break;
case 4:
FindEmp(wm,nmbwm , jsy,nmbjsy, jsjl,nmbjsjl, xsy,nmbsxy, xsjl,nmbxsjl);
break;
case 5:
bwork = false;
break;
}
}
return 0;
}