#include<iostream>
#include<string>
#include<fstream>
using namespace std;
class Staff
{
public:
string m_Code;
string m_Name;
string m_DepartmentCode;
string m_Job;
string m_Position;
Staff* ptr_Position;
virtual string ShowJob()
{
return 0;
}
};
class NormalEmployee :public Staff
{
public:
string m_Job;
string m_Position;
NormalEmployee()
{
this->m_Job = "完成经理交付的任务";
this->m_Position = "普通员工";
}
virtual string ShowJob()
{
return this->m_Job;
}
};
class Manager :public Staff
{
public:
string m_Job;
string m_Position;
Manager()
{
this->m_Job = "完成老板交付的任务,并将任务下发给员工";
this->m_Position = "经理";
}
virtual string ShowJob()
{
return this->m_Job;
}
};
class Boss :public Staff
{
public:
string m_Job;
string m_Position;
Boss()
{
this->m_Job = "管理公司所有事务";
this->m_Position = "老板";
}
virtual string ShowJob()
{
return this->m_Job;
}
};
int len=0;
Staff AllStaff[1000];
void AddStaff(Staff* arr,int& size)
{
string name;
string code,code1;
cout << "请输入员工姓名" << endl;
cin >> name;
arr[size].m_Name = name;
cout << "请输入职工编号" << endl;
cin >> code;
arr[size].m_Code = code;
cout << "请输入部门编号" << endl;
cin >> code1;
arr[size].m_DepartmentCode = code1;
cout << "请输入职工岗位" << endl;
cin >> name;
arr[size].m_Position = name;
if (arr[size].m_Position == "普通员工")
{
arr[size].ptr_Position = new NormalEmployee;
arr[size].m_Job = arr[size].ShowJob();
}
else if (arr[size].m_Position == "经理")
{
arr[size].ptr_Position = new Manager;
//arr[size].m_Job = arr[size].ShowJob();
}
else if (arr[size].m_Position == "老板")
{
arr[size].ptr_Position = new Boss;
arr[size].m_Job = arr[size].ShowJob();
}
size++;
cout << "添加成功!" << endl;
}
int main()
{
int choice;
int i = 0;
PrintMenu();
cin >> choice;
while (true)
{
if (i != 0)
{
PrintMenu();
cin >> choice;
}
switch (choice)
{
case 1:
cout << "欢迎您的再次使用!" << endl;
return 0;
case 2:
AddStaff(AllStaff,len);
break;
case 3:
ShowStaff(AllStaff, len);
break;
case 4:
DeleteStaff(AllStaff, len);
break;
case 5:
ModifyStaff(AllStaff, len);
break;
case 6:
SearchStaff(AllStaff, len);
break;
case 7:
Demendorder(AllStaff, len);
break;
case 8:
DeleteAll(len);
break;
default:
system("cls");
cout << "\t请输入正确的数字选项!" << endl;
cout << "\t";
system("pause");
break;
}
i++;
system("cls");
}
}