#pragma once
#include<iostream>
#include"worker0.h"
#include"manager.h"
#include"boss.h"
#include"employ.h"
using namespace std;
class workermanger
{
public:
~workermanger();
void exitsystem();
void show_menu();
int m_empnum;
worker** m_emparray;
void add_emp();
void show_emp();
bool m_Fileisempty;
};
#include"workermanger.h"
void workermanger::show_menu()
{
cout << "*****************************************" << endl;
cout << "********* 欢迎使用职工管理系统 **********" << endl;
cout << "*********** 0.退出管理系统 ************" << endl;
cout << "*********** 1.增加职工信息 ************" << endl;
cout << "*********** 2.显示职工信息 ************" << endl;
cout << "*********** 3.删除离职职工 ************" << endl;
cout << "*********** 4.修改职工信息 ************" << endl;
cout << "*********** 5.查找职工信息 ************" << endl;
cout << "*********** 6.按照编号排序 ************" << endl;
cout << "*********** 7.清空所有文档 ************" << endl;
cout << "*****************************************" << endl;
cout << endl;
}
void workermanger::exitsystem()
{
cout << "欢迎下次使用" << endl;
system("pause");
exit(0);
}
void workermanger::add_emp()
{
cout << "请输入添加苦力工的数量:" << endl;
int addnum = 0;
cin >> addnum;
if (addnum > 0)
{
int newsize = this->m_empnum + addnum;
worker**newspace= new worker* [newsize];
if (this->m_empnum != 0)
{
for (int i = 0; i < this->m_empnum; i++)
{
newspace[i] = this->m_emparray[i];
}
}
for (int i = 0; i < addnum; i++)
{
int id;
string name;
int dselect;
cout << "请输入第" << i + 1 << "个新职工编号" << endl;
cin >> id;
cout << "请输入第" << i + 1 << "个新职工姓名" << endl;
cin >> name;
cout << "请输入第" << i + 1 << "个新职工岗位" << endl;
cout << "1.苦力工" << endl;
cout << "2.周扒皮" << endl;
cout << "3.李老板" << endl;
cin >> dselect;
worker* worker = NULL;
switch (dselect)
{
case1:
worker = new employee(id, name, 1);
break;
case2:
worker = new manager(id, name, 2);
break;
case3:
worker = new boss(id, name, 3);
break;
dafault:
break;
}
newspace[this->m_empnum + i] = worker;
}
delete[]this->m_emparray;
this->m_emparray = newspace;
this->m_empnum = newsize;
cout << "添加成功" << addnum << "公司成员" << endl;
}
else
cout << "我一眼看穿你不是人" << endl;
}
void workermanger::show_emp()
{
for (int i = 0; i < m_empnum; i++)
{
this->m_emparray[i]->showinfo();
}
system("pause");
}
workermanger::~workermanger()
{
if (this->m_emparray != NULL)
{
delete[]this->m_emparray;
this->m_emparray = NULL;
}
}
#include<iostream>
using namespace std;
#include"workermanger.h"
#include"worker0.h"
#include"employ.h"
#include"manager.h"
#include"boss.h"
int main()
{
workermanger wm;
int choice = 0;
while (true)
{
wm.show_menu();
cout << "请输入您的选择: " << endl;
cin >> choice;
switch (choice)
{
case 0:wm.exitsystem();
break;
case 1://增加职工
wm.add_emp();
break;
case 2://显示职工
wm.show_emp();
break;
case 3://删除职工
break;
case 4://修改职工
break;
case 5://查找职工
break;
case 6://排序职工
break;
case 7://清空文档
break;
default:
system("cls");
break;
}
}
system("pause");
return 0;
}
#pragma once
#include<iostream>
using namespace std;
#include"worker0.h"
class boss :public worker
{
public:
boss(int id, string name, int did);
virtual void showinfo();
virtual string getdeptname();
};
#include"boss.h"
boss::boss(int id, string name, int did)
{
this->m_id = id;
this->m_name = name;
this->m_deptid = did;
}
void boss::showinfo()
{
cout << "职工编号:" << this->m_id
<< "\t职工姓名:" << this->m_name
<< "\t职位:" << this->getdeptname()
<< "\t岗位职责:压榨经理老板,天天tv泡妞" << endl;
}
string boss::getdeptname()
{
return string("李老板");
}
#include"manager.h"
manager::manager(int id, string name, int did)
{
this->m_id = id;
this->m_name = name;
this->m_deptid = did;
}
void manager::showinfo()
{
cout << "职工编号:" << this->m_id
<< "\t职工姓名:" << this->m_name
<< "\t职位:" << this->getdeptname()
<< "\t岗位职责:压榨普通员工当周扒皮,并且拍老板马屁" << endl;
}
string manager::getdeptname()
{
return string("周扒皮");
}
#pragma once
#include<iostream>
using namespace std;
#include"worker0.h"
class manager :public worker
{
public:
manager(int id, string name, int did);
virtual void showinfo();
virtual string getdeptname();
};
#pragma once
#include<iostream>
using namespace std;
#include"worker0.h"
class employee :public worker
{
public:
employee(int id,string name,int did);
virtual void showinfo();
virtual string getdeptname();
};
#include"employ.h"
employee::employee(int id, string name, int did)
{
this->m_id = id;
this->m_name = name;
this->m_deptid = did;
}
void employee::showinfo()
{
cout << "职工编号:" << this->m_id
<< "\t职工姓名:" << this->m_name
<< "\t职位:" << this->getdeptname()
<< "\t岗位职责:当苦力工完成最苦最累的任务" << endl;
}
string employee::getdeptname()
{
return string("苦力工");
}