日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

c++面向对象程序设计大作业(人事管理系统)

發(fā)布時間:2023/12/29 c/c++ 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c++面向对象程序设计大作业(人事管理系统) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1.登錄

Administrator_login.h

#pragma once #include"controller.h" #include<string> #include<fstream> #define FILENAME3 "password.txt" using namespace std; class Login { public:Login();void login(); public:Controller con; private:string str; };

Administrator_login1.cpp

#include"Administrator_login.h" Login::Login() {ifstream ifs;ifs.open(FILENAME3, ios::in);if (!ifs.is_open()){cout << "未設(shè)置密碼" << endl;ifs.close();return;}elseifs >> str;ifs.close(); } void Login:: login() {string s;cout << "請輸入登錄密碼" << endl;cin >> s;if (s == this->str){this->con.Choice();}else{cout << "密碼錯誤,非管理員禁止登錄!" << endl;exit(-1);} }

2.董事長類

boss.h

#pragma once #include<iostream> #include"Work.h" using namespace std; class Boss :public Work { public:Boss(int id, string name, int depid);virtual void Show_Information();virtual string Get_position_name(); };

boss,cpp

#include"boss.h" using namespace std; Boss::Boss(int id, string name, int depid) {this->n_ID = id;this->n_Name = name;this->n_Dep_number = depid; } void Boss::Show_Information() {cout << "職工編號:" << this->n_ID << endl;cout << "職工姓名:" << this->n_Name << endl;cout << "職工部門:" << this->n_Dep_number << endl;cout << "職工職責(zé):管理經(jīng)理" << endl; } string Boss::Get_position_name() {return string("懂事長"); }

3.應(yīng)聘者類

Candidate.h

#pragma once #include<iostream> #include"user.h" class Candidate :public User { public:Candidate(int id, string name, int depid);void Show_Information();string Get_Motivation(); };

Candidate.cpp

#include"Candidate.h" Candidate::Candidate(int id, string name, int depid) {this->id = id;this->n_Name = name;this->depid = depid; } void Candidate::Show_Information() {cout << "訪客id為:" << this->id << endl;cout << "訪客姓名為:" << this->n_Name << endl;cout << "訪客類型為:" << this->depid << endl; } string Candidate::Get_Motivation() {string s("前來公司應(yīng)聘");return s; }

4.控制

controller.h

#pragma once #include<iostream> #include"Menu.h" #include"Manager_User.h" #include"Manager_Work.h" #include"head_view.h" class Controller { public://系統(tǒng)選擇void Choice();//展示用戶菜單void Show_Menu_user();//展示職員菜單void Show_Menu_work();//查看信息void view();//進(jìn)入職員系統(tǒng)void Choice_work();//進(jìn)入用戶系統(tǒng)void Choice_User(); public:Menu menu;Manager_User user;Manager_Work work; };

constroller.cpp

#include"controller.h" void Controller::Choice() {cout << "請輸入對應(yīng)數(shù)字選擇管理系統(tǒng)" << endl;cout << "1 職員管理" << endl;cout << "2 用戶管理" << endl;int select = 0;cin >> select;try{if (select == 2){Show_Menu_user();Choice_User();}else if (select == 1){Show_Menu_work();Choice_work();}if (select != 1 && select != 2){throw(-1);}}catch (int a){cout << "輸入錯誤" << endl;cout << "請重新輸入" << endl;while (1){cin >> select;if (select == 2){Show_Menu_user();Choice_User();break;}else if (select == 1){Show_Menu_work();Choice_work();break;}cout << "輸入錯誤" << endl;cout << "請重新輸入" << endl;}//return;} } void Controller::Choice_User() {//選擇編號int n;cout << "請輸入你的選擇" << endl;cin >> n;//提供分支選擇,提供每個功能接口while (1){if (n == 0){user.Exit_the_system();//退出管理系統(tǒng)break;}switch (n){//增加用戶信息case 1:user.Add_Person();break;//顯示case 2:user.Show_inf();break;//查找case 3:user.Find_user();break;default:system("cls");break;}Show_Menu_user();cout << "請輸入你的選擇" << endl;cin >> n;}} void Controller::Choice_work() {//選擇編號int n;cout << "請輸入你的選擇" << endl;cin >> n;//提供分支選擇,提供每個功能接口while (1){if (n == 0){work.Exit_the_system();//退出管理系統(tǒng)break;}switch (n){//增加職工信息case 1:work.Add_Person();break;//顯示case 2:work.Show_inf();break;//刪除case 3:work.Delete_P();break;//修改case 4:work.Revise_Per();break;//查找case 5:work.Find_per();break;//排序case 6:work.Sort_per();break;//清空case 7:work.Clear_File();break;default:system("cls");break;}Show_Menu_work();cout << "請輸入你的選擇" << endl;cin >> n;}} void Controller::view() {Manager_User user;Manager_Work work;Head_view vi(user, work);vi.View_user();vi.View_work(); } void Controller::Show_Menu_user() {this->menu.menu_user(); } void Controller::Show_Menu_work() {this->menu.menu_work(); }

5.視圖

head_view.h

#pragma once #include<iostream> #include"Manager_User.h" #include"Manager_Work.h" using namespace std; class Head_view { public:Head_view(Manager_User user,Manager_Work work){this->n_User = user;this->n_Work = work;}void View_user(){this->n_User.Show_inf();}void View_work(){this->n_Work.Show_inf();} public:Manager_User n_User;Manager_Work n_Work; };

6.總經(jīng)理

Manager.h

#pragma once #include<iostream> #include"Work.h" using namespace std; class Manager:public Work { public:Manager(int id, string name, int depid);virtual void Show_Information();virtual string Get_position_name(); };

Manager.cpp

#include"Manager.h" using namespace std;Manager::Manager(int id, string name, int depid) {this->n_ID = id;this->n_Name = name;this->n_Dep_number = depid; } void Manager::Show_Information() {cout << "職工編號:" << this->n_ID << endl;cout << "職工姓名:" << this->n_Name << endl;cout << "職工部門:" << this->n_Dep_number << endl;cout << "職工職責(zé):完成董事長的任務(wù)" << endl; } string Manager::Get_position_name() {return string("總經(jīng)理"); }

7.管理用戶

Manager_User.h

#pragma once #include<iostream> #include<fstream> #include"visitor.h" #include"Candidate.h" #include"VIP.h" #include"user.h" //#include"controller.h" #define FILENAME2 "user.txt" using namespace std; class Manager_User { public:Manager_User();//保存文件void Save();void Show_inf();//獲取用戶數(shù)量int get_usernumber();//初始化用戶void init_user();//增加用戶void Add_Person();//退出系統(tǒng)void Exit_the_system();//查找用戶void Find_user();//判斷用戶是否存在int IsExist(int id);public://用戶人數(shù)int user_num;//標(biāo)志文件是否為空bool n_FileIsEmpty;//用戶數(shù)組指針User** array; };

Manager_User.cpp

#include"Manager_User.h" #include<iostream> Manager_User::Manager_User() {ifstream ifs;ifs.open(FILENAME2, ios::in);//1.文件不存在情況if (!ifs.is_open()){cout << "文件不存在" << endl;//初始化屬性this->user_num = 0;this->array = NULL;this->n_FileIsEmpty = true;ifs.close();return;}//2.文件存在,但是數(shù)據(jù)為空char ch;//讀一個字符ifs >> ch;//如果讀完了,文件為空if (ifs.eof()){cout << "文件為空!" << endl;//初始化屬性this->user_num = 0;this->array = NULL;this->n_FileIsEmpty = true;//關(guān)閉文件ifs.close();return;}//3.文件存在,數(shù)據(jù)也存在int num = this->get_usernumber();//更新用戶數(shù)量this->user_num = num;//根據(jù)用戶數(shù)量創(chuàng)建數(shù)組this->array = new User * [this->user_num];//開辟空間//初始化用戶//將文件中的數(shù)據(jù)存到數(shù)組中init_user(); } void Manager_User::Show_inf() {//先判斷文件是否為空if (this->n_FileIsEmpty){cout << "文件不存在或者文件為空" << endl;}//不為空時//用多態(tài)調(diào)用程序接口else{for (int i = 0; i < user_num; i++){cout << "用戶類型為:" << this->array[i]->Get_Motivation() << endl;this->array[i]->Show_Information();cout << endl;}//按任意鍵后清屏system("pause");system("cls");} } int Manager_User::get_usernumber() {ifstream ifs;//以讀文件方式打開文件ifs.open(FILENAME2, ios::in);int id;int depid;string name;int num = 0;//記錄人數(shù)while (ifs >> id && ifs >> name && ifs >> depid){//每讀取一行人數(shù)+1num++;}ifs.close();return num; } void Manager_User::Save() {ofstream ofs;//寫入文件ofs.open(FILENAME2, ios::out);//將每個人的數(shù)據(jù)寫到文件中for (int i = 0; i < this->user_num; i++){ofs << this->array[i]->id << " "<< this->array[i]->n_Name << " "<< this->array[i]->depid << endl;}ofs.close(); } void Manager_User::init_user() {ifstream ifs;//以讀文件方式打開ifs.open(FILENAME2, ios::in);string name;int id;int depid;int index = 0;while (ifs >> id && ifs >> name && ifs >> depid){User* p = NULL;//根據(jù)不同的部門id創(chuàng)建不同的對象if (depid == 1)p = new Visitor(id, name, depid);else if (depid == 2)p = new Candidate(id, name, depid);else{p = new Vip(id, name, depid);}//存放在數(shù)組中this->array[index] = p;index++;}ifs.close(); } void Manager_User::Add_Person() {cout << "請輸入添加用戶的數(shù)量" << endl;//記錄添加用戶數(shù)量int add_num = 0;cin >> add_num;if (add_num > 0){//新空間的大小=原來人數(shù)+新增人數(shù)int newSize = this->user_num + add_num;//開辟新空間User** newSpace = new User * [newSize];if (this->array){for (int i = 0; i < this->user_num; i++){newSpace[i] = this->array[i];}}//批量添加數(shù)據(jù)for (int i = 0; i < add_num; i++){//用戶編號int id;//用戶姓名string name;//用戶類型int dSelect;cout << "請輸入第" << i + 1 << "個用戶id" << endl;cin >> id;cout << "請輸入第" << i + 1 << "個用戶姓名:" << endl;cin >> name;cout << "請輸入第" << i + 1 << "個用戶類型:" << endl;cout << "請選擇用戶類型:" << endl;cout << "3-VIP" << endl;cout << "2-應(yīng)聘者" << endl;cout << "1-訪客" << endl;cin >> dSelect;User* p = NULL;switch (dSelect){case 1:p = new Visitor(id, name, 1);break;case 2:p = new Candidate(id, name, 2);break;case 3:p = new Vip(id, name, 3);break;}newSpace[this->user_num + i] = p;}//先釋放原有空間delete[] this->array;//更改新空間的指向this->array = newSpace;//更新用戶人數(shù)this->user_num = newSize;cout << "已成功添加" << add_num << "名用戶" << endl;//保存數(shù)據(jù)到文件中this->Save();}else{cout << "輸入有誤" << endl;}//按任意鍵后清屏回到上級目錄system("pause");system("cls"); } void Manager_User::Exit_the_system() {cout << "感謝使用" << endl;system("pause");exit(0); } void Manager_User::Find_user() {if (this->n_FileIsEmpty){cout << "文件不存在或文件為空!" << endl;}else{cout << "請輸入查找的方式:" << endl;cout << "1 按用戶編號查找" << endl;cout << "2 按用戶姓名查找" << endl;int select = 0;cin >> select;if (select == 1){//按照編號查int id;cout << "請輸入查找的用戶編號:" << endl;cin >> id;//先判斷該職工是否存在int ret = IsExist(id);if (ret != -1){//找到職工cout << "查找成功!該職工信息如下:" << endl;this->array[ret]->Show_Information();}else{cout << "查無此人!" << endl;}}else if (select == 2){//按照姓名查string name;cout << "請輸入查找的姓名:" << endl;cin >> name;//加入判斷是否查到的標(biāo)志bool flag = false;//默認(rèn)未找到用戶for (int i = 0; i < user_num; i++){if (this->array[i]->n_Name == name){cout << "查找成功!用戶編號為" << this->array[i]->id << "號用戶信息如下:" << endl;flag = true;this->array[i]->Show_Information();//調(diào)用顯示信息的函數(shù)}}if (flag == false){cout << "查無此人!" << endl;}}else{cout << "輸入的選項有誤!" << endl;}}//按任意鍵清屏system("pause");system("cls"); } int Manager_User::IsExist(int id) {//一開始認(rèn)定不在int index = -1;for (int i = 0; i < this->user_num; i++){if (this->array[i]->id == id){index = i;break;//找到即可退出}}return index; }

8.管理職員

Manager_Work.h

#pragma once #include<iostream> #include"Manager.h" #include"personnel.h" #include"Work.h" #include"boss.h" #include"project_manager.h" #include"sales_manager.h" //#include"controller.h" #include<fstream> #define FILENAME "empFile.txt" using namespace std; class Manager_Work { public://初始化Manager_Work();//退出系統(tǒng)void Exit_the_system();//添加職工void Add_Person();//保存文件void Save();//統(tǒng)計人數(shù)int get_pernumber();//初始化員工void init_personnel();//顯示職工void Show_inf();//刪除職工void Delete_P();//按照職工編號判斷職工是否存在int IsExist(int id);//修改職工void Revise_Per();//查找職工void Find_per();//排序void Sort_per();//清空文件void Clear_File();//清理~Manager_Work(); public://職工人數(shù)int n_pernumber;//職工數(shù)組指針Work** array;//標(biāo)志文件是否為空bool n_FileIsEmpty;//如果文件為空,就不進(jìn)行顯示,修改,刪除等操作 };

Manager_Work.cpp

#include"Manager_Work.h" #include<iostream> using namespace std; Manager_Work::Manager_Work() {//分類討論:ifstream ifs;ifs.open(FILENAME, ios::in);//1.文件不存在if (!ifs.is_open()){cout << "文件不存在" << endl;//初始化屬性this->n_pernumber = 0;this->array = NULL;this->n_FileIsEmpty = true;ifs.close();return;}//2.文件存在數(shù)據(jù)為空char ch;//走讀一個字符ifs >> ch;//如果讀完了,文件為空if (ifs.eof()){cout << "文件為空!" << endl;//初始化屬性this->n_pernumber = 0;this->array = NULL;this->n_FileIsEmpty = true;//關(guān)閉文件ifs.close();return;}//3.文件存在,數(shù)據(jù)存在int num = this->get_pernumber();//更新成員屬性this->n_pernumber = num;//根據(jù)職工數(shù)創(chuàng)建數(shù)組this->array = new Work * [this->n_pernumber];//堆區(qū)開辟空間//初始化職工//將文件中的數(shù)據(jù)存到數(shù)組中init_personnel(); }void Manager_Work::Revise_Per() {if (this->n_FileIsEmpty){cout << "文件不存在或者文件為空" << endl;}else{cout << "請輸入修改職工的編號" << endl;int id;cin >> id;//判斷職工是否存在int n = this->IsExist(id);if (n != -1){//查找到職工編號//刪除掉該位置的數(shù)據(jù)delete this->array[n];//每個數(shù)據(jù)都重新修改一下//初始狀態(tài)int new_id = 0;string new_name = " ";int dSelect = 0;cout << "查找到" << id << "職工,請輸入新的職工編號" << endl;cin >> new_id;cout << "請輸入姓名:" << endl;cin >> new_name;cout << "請輸入崗位" << endl;cout << "5-項目經(jīng)理" << endl;cout << "4-銷售經(jīng)理" << endl;cout << "3-老板" << endl;cout << "2-總經(jīng)理" << endl;cout << "1-員工" << endl;cin >> dSelect;//重新申請空間Work* p = NULL;switch (dSelect){case 1:p = new Personnel(new_id, new_name, dSelect);break;case 2:p = new Manager(new_id, new_name, dSelect);break;case 3:p = new Boss(new_id, new_name, dSelect);case 4:p = new Sales_manager(new_id, new_name, dSelect);case 5:p = new Porject_Manager(new_id, new_name, dSelect);break;}//更改數(shù)據(jù)到數(shù)組中this->array[n] = p;cout << "修改成功" << this->array[n]->n_Dep_number << endl;//保存到文件中this->Save();}else{cout << "職工不存在,修改失敗" << endl;}}// 按任意鍵清屏system("pause");system("cls"); } //查找職工信息 void Manager_Work::Find_per() {if (this->n_FileIsEmpty){cout << "文件不存在或文件為空!" << endl;}else{cout << "請輸入查找的方式:" << endl;cout << "1 按職工編號查找" << endl;cout << "2 按職工姓名查找" << endl;int select = 0;cin >> select;if (select == 1){//按照編號查int id;cout << "請輸入查找的職工編號:" << endl;cin >> id;//先判斷該職工是否存在int ret = IsExist(id);if (ret != -1){//找到職工cout << "查找成功!該職工信息如下:" << endl;this->array[ret]->Show_Information();}else{cout << "查無此人!" << endl;}}else if (select == 2){//按照姓名查string name;cout << "請輸入查找的姓名:" << endl;cin >> name;//加入判斷是否查到的標(biāo)志bool flag = false;//默認(rèn)未找到職工for (int i = 0; i < n_pernumber; i++){if (this->array[i]->n_Name == name){cout << "查找成功!職工編號為" << this->array[i]->n_ID << "號職工信息如下:" << endl;flag = true;this->array[i]->Show_Information();//調(diào)用顯示信息的函數(shù)}}if (flag == false){cout << "查無此人!" << endl;}}else{cout << "輸入的選項有誤!" << endl;}}//按任意鍵清屏system("pause");system("cls"); } void Manager_Work::Clear_File() {cout << "請確認(rèn)是否清空" << endl;cout << "輸入1 確認(rèn)" << endl;cout << "輸入0 返回" << endl;int select = 0;cin >> select;if (select == 1){//刪除文件后重新創(chuàng)建ofstream ofs(FILENAME, ios::trunc);ofs.close();if (this->array){//逐個刪除for (int i = 0; i < this->n_pernumber; i++){delete this->array[i];//置空this->array[i] = NULL;}//刪除堆區(qū)數(shù)組指針delete[]this->array;this->array = NULL;//職工人數(shù)置零this->n_pernumber = 0;//文件為空的標(biāo)志置為truethis->n_FileIsEmpty = true;cout << "清空成功!" << endl;}} } void Manager_Work::Show_inf() {//先判斷文件是否為空if (this->n_FileIsEmpty){cout << "文件不存在或者文件為空" << endl;}//不為空時//用多態(tài)調(diào)用程序接口else{for (int i = 0; i < n_pernumber; i++){cout << "職稱為:" << this->array[i]->Get_position_name() << endl;this->array[i]->Show_Information();cout << endl;}//按任意鍵后清屏system("pause");system("cls");} } int Manager_Work::IsExist(int id) {//一開始認(rèn)定不在int index = -1;for (int i = 0; i < this->n_pernumber; i++){if (this->array[i]->n_ID == id){index = i;break;//找到即可退出}}return index; } void Manager_Work::Delete_P() {if (this->n_FileIsEmpty){cout << "文件不存在或者文件為空" << endl;}else{//按照職工編號刪除cout << "請輸入想刪除的職工編號" << endl;int id = 0;cin >> id;//判斷職工是否存在int index = this->IsExist(id);if (index != -1)//如果職工存在{//該位置后的所有數(shù)據(jù)前移for (int i = index; i < this->n_pernumber; i++){this->array[i] = this->array[i + 1];}this->n_pernumber--;//數(shù)據(jù)同步更新到文件中this->Save();cout << "刪除成功" << endl;}else{cout << "該職工不存才,刪除失敗" << endl;}}//按任意鍵清屏system("pause");system("cls"); } void Manager_Work::Sort_per() {if (this->n_FileIsEmpty){cout << "文件不存在或為空" << endl;//按任意鍵清屏system("pause");system("cls");}else{cout << "請選擇職工排序方式" << endl;cout << "輸入0 按職工編號升序排序" << endl;cout << "輸入1 按職工編號降序排序" << endl;int select = 0;cin >> select;for (int i = 0; i < this->n_pernumber; i++){int max_or_min = i;//聲明最大值或最小值下標(biāo)if (select == 1)//降序{for (int j = i + 1; j < this->n_pernumber; j++){if (this->array[j]->n_ID > this->array[max_or_min]->n_ID){max_or_min = j;}}}else//升序{for (int j = i + 1; j < this->n_pernumber; j++){if (this->array[j]->n_ID < this->array[max_or_min]->n_ID){max_or_min = j;}}}if (i != max_or_min){Work* t = this->array[i];this->array[i] = this->array[max_or_min];this->array[max_or_min] = t;}}cout << "排序后的結(jié)果為:" << endl;this->Save();this->Show_inf();}} void Manager_Work::init_personnel() {ifstream ifs;//以讀文件方式打開ifs.open(FILENAME, ios::in);int id;string name;int depid;int index = 0;//數(shù)組下標(biāo)while (ifs >> id && ifs >> name && ifs >> depid){Work* p = NULL;//根據(jù)不同的部門id創(chuàng)建不同的對象if (depid == 1)p = new Personnel(id, name, depid);else if (depid == 2)p = new Manager(id, name, depid);else if (depid == 3)p = new Boss(id, name, depid);else if (depid == 4)p = new Sales_manager(id, name, depid);elsep = new Porject_Manager(id, name, depid);//存放在數(shù)組中this->array[index] = p;index++;}ifs.close(); } //清理操作 Manager_Work::~Manager_Work() {//釋放空間if (this->array){delete[]this->array;this->array = NULL;} } int Manager_Work::get_pernumber() {ifstream ifs;//以讀文件方式打開文件ifs.open(FILENAME, ios::in);int id;string name;int depid;int num = 0;while (ifs >> id && ifs >> name && ifs >> depid){num++;//人數(shù)++}ifs.close();return num; } void Manager_Work::Exit_the_system() {cout << "感謝使用" << endl;system("pause");exit(0); } void Manager_Work::Save() {ofstream ofs;//用輸出的方式打開文件,寫文件ofs.open(FILENAME, ios::out);//將每個人的數(shù)據(jù)寫到文件中for (int i = 0; i < this->n_pernumber; i++){ofs << this->array[i]->n_ID << " "<< this->array[i]->n_Name << " "<< this->array[i]->n_Dep_number << endl;}ofs.close(); } void Manager_Work::Add_Person() {cout << "請輸入添加職工的數(shù)量" << endl;//記錄添加職工數(shù)量int add_num = 0;cin >> add_num;if (add_num > 0){//新空間的大小=原來人數(shù)+新增人數(shù)int newSize = this->n_pernumber + add_num;//開辟新空間Work** newSpace = new Work * [newSize];if (this->array){for (int i = 0; i <this->n_pernumber; i++){newSpace[i] = this->array[i];}}//批量添加數(shù)據(jù)for (int i = 0; i < add_num; i++){//職工編號int id;//職工姓名string name;//部門選擇int dSelect;cout << "請輸入第" << i + 1 << "個職工編號:" << endl;cin >> id;cout << "請輸入第" << i + 1 << "個職工姓名:" << endl;cin >> name;cout << "請選擇職工崗位:" << endl;cout << "5-項目經(jīng)理" << endl;cout << "4-銷售經(jīng)理" << endl;cout << "3-老板" << endl;cout << "2-經(jīng)理" << endl;cout << "1-員工" << endl;cin >> dSelect;Work* p = NULL;switch (dSelect){case 1:p = new Personnel(id, name, 1);break;case 2:p = new Manager(id, name, 2);break;case 3:p = new Boss(id, name, 3);break;case 4:p= new Sales_manager(id, name, 4);break;case 5:p = new Porject_Manager(id, name, 5);}newSpace[this->n_pernumber + i] = p;}//先釋放原有空間delete[] this->array;//更改新空間的指向this->array = newSpace;//更新職工人數(shù)this->n_pernumber = newSize;cout << "已成功添加" << add_num << "名職工" << endl;//保存數(shù)據(jù)到文件中this->Save();}else{cout << "輸入有誤" << endl;}//按任意鍵后清屏回到上級目錄system("pause");system("cls"); }

9.菜單

Menu.h

#pragma once #include<iostream> #include"Menu_user.h" #include"Menu_work.h" using namespace std; class Menu { public:void menu_user(){this->m_user.menu_user();}void menu_work(){this->m_work.menu_work();} public:M_user m_user;M_work m_work; };

10.用戶菜單

Menu_user.h

#pragma once #include<iostream> using namespace std; class M_user { public:void menu_user(){cout << "歡迎使用用戶管理系統(tǒng)" << endl;cout << "0 退出管理系統(tǒng)" << endl;cout << "1 增加用戶信息" << endl;cout << "2 顯示用戶信息" << endl;cout << "3 查找用戶信息" << endl;} };

11.職員 菜單

Menu_work.h

#pragma once #include<iostream> using namespace std; class M_work { public:void menu_work(){cout << "歡迎使用職工管理系統(tǒng)" << endl;cout << "0 退出管理系統(tǒng)" << endl;cout << "1 增加職工信息" << endl;cout << "2 顯示職工信息" << endl;cout << "3 刪除離職職工" << endl;cout << "4 修改職工信息" << endl;cout << "5 查找職工信息" << endl;cout << "6 排序職工信息" << endl;cout << "7 清空所有數(shù)據(jù)" << endl;} };

12.普通職工

personnel.h

#pragma once #include<iostream> #include<string> #include"Work.h" class Personnel :public Work { public:Personnel(int id, string name, int depid);virtual void Show_Information();virtual string Get_position_name();};

personnel.cpp

#include"personnel.h" using namespace std; Personnel::Personnel(int id, string name, int depid) {this->n_ID = id;this->n_Name = name;this->n_Dep_number = depid; } void Personnel::Show_Information() {cout << "職工編號:" << this->n_ID << endl;cout << "職工姓名:" << this->n_Name << endl;cout << "職工部門:" << this->n_Dep_number << endl;cout << "職工職責(zé):完成經(jīng)理下達(dá)的任務(wù)"<< endl; } string Personnel::Get_position_name() {return string("初級員工"); }

13.項目經(jīng)理

project_manager.h

#pragma once #include<iostream> #include"Work.h" using namespace std;class Porject_Manager :public Work { public:Porject_Manager(int id, string name, int depid);virtual void Show_Information();virtual string Get_position_name(); }; project_manager.cpp```cpp #include"project_manager.h"Porject_Manager::Porject_Manager(int id, string name, int depid) {this->n_ID = id;this->n_Name = name;this->n_Dep_number = depid; } void Porject_Manager::Show_Information() {cout << "職工編號:" << this->n_ID << endl;cout << "職工姓名:" << this->n_Name << endl;cout << "職工部門:" << this->n_Dep_number << endl;cout << "職工職責(zé):管理項目" << endl; } string Porject_Manager::Get_position_name() {return string("項目經(jīng)理"); }

14.銷售經(jīng)理

sales_manager.h

#pragma once #include<iostream> #include"Work.h" using namespace std; class Sales_manager :public Work { public:Sales_manager(int id, string name, int depid);void Show_Information();string Get_position_name();};

sales_manager.cpp

#include"sales_manager.h"Sales_manager::Sales_manager(int id, string name, int depid) {this->n_ID = id;this->n_Name = name;this->n_Dep_number = depid; } void Sales_manager::Show_Information() {cout << "職工編號:" << this->n_ID << endl;cout << "職工姓名:" << this->n_Name << endl;cout << "職工部門:" << this->n_Dep_number << endl;cout << "職工職責(zé):管理銷售" << endl; } string Sales_manager::Get_position_name() {return string("銷售經(jīng)理"); }

15.用戶

user.h

#pragma once #include<iostream> #include<string> using namespace std; class User { public:virtual void Show_Information() = 0;//純虛virtual string Get_Motivation() = 0;int id;string n_Name;int depid; };

16.VIP

VIP.h

#pragma once #include<iostream> #include"user.h" class Vip :public User { public:Vip(int id, string name, int depid);void Show_Information();string Get_Motivation(); };

VIP.cpp

#include"VIP.h" Vip::Vip(int id, string name, int depid) {this->id = id;this->n_Name = name;this->depid = depid; } void Vip::Show_Information() {cout << "訪客id為:" << this->id << endl;cout << "訪客姓名為:" << this->n_Name << endl;cout << "訪客類型為:" << this->depid << endl; } string Vip::Get_Motivation() {string s("享受公司所有服務(wù)");return s; }

17.訪客

visitor.h

#pragma once #include<iostream> #include"user.h" class Visitor :public User { public:Visitor(int id,string name,int depid);void Show_Information();string Get_Motivation(); };

visitor.cpp

#include"visitor.h" Visitor::Visitor(int id,string name,int depid) {this->id = id;this->n_Name = name;this->depid = depid; } void Visitor::Show_Information() {cout << "訪客id為:" << this->id << endl;cout << "訪客姓名為:" << this->n_Name << endl;cout << "訪客類型為:" << this->depid << endl; } string Visitor::Get_Motivation() {string s("刷視頻看到本公司");return s; }

18.職員

Work.h

#pragma once #include<iostream> #include<string> using namespace std; //職工類 class Work { public:virtual void Show_Information() = 0;//純虛virtual string Get_position_name() = 0;int n_ID;//職工編號string n_Name;//職工姓名int n_Dep_number;//部門編號 };

19.主函數(shù)

main.cpp

#pragma once #include<iostream> #include"boss.h" #include"Manager.h" #include"Manager_Work.h" #include"personnel.h" #include"Work.h" #include"Manager_User.h" #include"project_manager.h" #include"sales_manager.h" #include"visitor.h" #include"Candidate.h" #include"VIP.h" #include"user.h" #include"head_view.h" #include"controller.h" #include"Menu.h" #include"Administrator_login.h" //#include<graphics.h> using namespace std; int main() {//登錄Login l;l.login();return 0; }

總結(jié)

以上是生活随笔為你收集整理的c++面向对象程序设计大作业(人事管理系统)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。