版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上 C+大作業(yè)報(bào)告 班級(jí): 學(xué)號(hào):姓名:銷售公司員工管理一題目:設(shè)計(jì)一個(gè)虛基類Staff(員工),包含編號(hào)、姓名和年齡保護(hù)數(shù)據(jù)成員以及相關(guān)的成員函數(shù);由Staff派生出銷售員類Salesman,包含銷售額保護(hù)數(shù)據(jù)成員以及相關(guān)的成員函數(shù);再由Staff派生出經(jīng)理類Manager;然后由Salesman和Manager類派生出銷售經(jīng)理類SalesManager。設(shè)計(jì)一個(gè)利用文件處理方式實(shí)現(xiàn)對(duì)公司人員(包括銷售員、經(jīng)理和銷售經(jīng)理)進(jìn)行管理,具有增加數(shù)據(jù)、更新數(shù)據(jù)、查詢數(shù)據(jù)、刪除數(shù)據(jù)以及重組文件的功能。(刪除數(shù)據(jù)在記錄中做刪除標(biāo)志,重組文件指在物理上刪除有刪除標(biāo)志的記錄。)另外
2、要求分別統(tǒng)計(jì)這三類員工的人數(shù)以及所有員工的總數(shù)。二 分析,流程及編程思想:首先定義一個(gè)虛基類Staff類,然后通過虛擬繼承生成Salesman類和Manager類,最后由Salesman和Manager派生出銷售經(jīng)理類SalesManager。這四個(gè)類中定義InputFromFile(istream &in)這一輸入函數(shù),另外每個(gè)類還定義輸入信息和輸出信息的成員函數(shù),之后定義StaffChart、SalesmanChart、ManagerChart和SalesManagerChart四個(gè)類來,為實(shí)現(xiàn)增加、更新、查詢、刪除以及特定類別人員顯示,特定類別人員數(shù)目顯示的功能定義addItem
3、、modifyItem、find、removeItem以及display、findnumber函數(shù)。最后在主函數(shù)定義Staff_Chart、Salesman_Chart、Manager_Chart和SalesManager_Chart四個(gè)對(duì)象,通過循環(huán)執(zhí)行并用switch函數(shù)選擇功能,然后調(diào)用相關(guān)的函數(shù)來實(shí)現(xiàn)各種功能。三 實(shí)驗(yàn)代碼:#include"iostream"#include"fstream"using namespace std;class Staff protected:char num10;char name10;int age;publi
4、c:Staff * Next;void set_staff()cout<<"Please enter a number:"cin>>num;cout<<"Please input the name:"cin>>name;cout<<"Please input the age:"cin>>age;void InputFromFile(istream &in)in>>num>>name>>age;void show()cou
5、t<<"number:"<<num<<endl;cout<<"name:"<<name<<endl;cout<<"age:"<<age<<endl;char *get_num()return num;char *get_name()return name;int get_age()return age;class Salesman:virtual public Staffprotected:int sales;public:Sa
6、lesman * Next;void set_salesman()cout<<"Please enter a number:"cin>>num;cout<<"Please input the name:"cin>>name;cout<<"Please input the age:"cin>>age;cout<<"Please enter the sales:"cin>>sales;void InputFromFile(i
7、stream &in)in>>num>>name>>age>>sales;void show_salesman()cout<<"number:"<<num<<endl;cout<<"name:"<<name<<endl;cout<<"age:"<<age<<endl;cout<<"sales:"<<sales<<end
8、l;int get_sales()return sales;class Manager:virtual public Staffprotected:char job10;char dept10;public:Manager * Next;void set_manager()cout<<"Please enter a number:"cin>>num;cout<<"Please input the name:"cin>>name;cout<<"Please input the age:&
9、quot;cin>>age;cout<<"Please input position:"cin>>job;cout<<"Please enter the Department:"cin>>dept;void InputFromFile(istream &in)in>>num>>name>>age>>job>>dept;void show_manager()cout<<"number:"<&l
10、t;num<<endl;cout<<"name:"<<name<<endl;cout<<"age:"<<age<<endl;cout<<"position:"<<job<<endl;cout<<"department:"<<dept<<endl;char *get_job()return job;char *get_dept()return dept;class
11、 SalesManager:public Salesman,public Managerpublic:SalesManager * Next;void set_salesmanager()cout<<"Please enter a number:"cin>>num;cout<<"Please input the name:"cin>>name;cout<<"Please input the age:"cin>>age;cout<<"Pleas
12、e enter the sales:"cin>>sales;cout<<"Please input position:"cin>>job;cout<<"Please enter the Department:"cin>>dept;void InputFromFile(istream &in)in>>num>>name>>age>>sales>>job>>dept;void show_salesmanager
13、()cout<<"number:"<<num<<endl;cout<<"name:"<<name<<endl;cout<<"age:"<<age<<endl;cout<<"sales:"<<sales<<endl;cout<<"position:"<<job<<endl;cout<<"depart
14、ment:"<<dept<<endl;class StaffChartpublic:StaffChart();StaffChart();void find(); void save(); void modifyItem(); void removeItem(); int findnumber(); void display() Staff *p=Head->Next;for(p;p!=End;p=p->Next)p->show();cout<<endl;void addItem() End->set_staff();End-
15、>Next=new Staff;End=End->Next;save();private:Staff * Head,* End;ifstream in; ofstream out; Staff * findItem(char * num)for(Staff * p=Head;p->Next!=End;p=p->Next)if(!strcmp(p->Next->get_num() ,num)return p;return NULL;StaffChart:StaffChart() Head=new Staff;Head->Next=new Staff;En
16、d=Head->Next;in.open("StaffChart.txt");while(!in.eof()End->InputFromFile(in);if(End->get_num()0='0')break;End->Next=new Staff;End=End->Next;in.close();StaffChart:StaffChart() for(Staff * temp;Head->Next!=End;)temp=Head->Next;Head->Next=Head->Next->Next
17、;delete temp;delete Head,End;void StaffChart:find() char num10;Staff * p=NULL;cout<<"Please input the search for employee number:"cin>>num;if(p=findItem(num)p->Next->show();elsecout<<"Not found!"<<endl<<endl;void StaffChart:modifyItem() char nu
18、m10;Staff * p=NULL;cout<<"Please input to modify the employee number:"cin>>num;if(p=findItem(num)p->Next->show();cout<<"Please input the new content:"<<endl;p->Next->set_staff();elsecout<<"Not found!"<<endl<<endl;sav
19、e();void StaffChart:removeItem() char num10;Staff *p=NULL,*temp=NULL;cout<<"Please delete employee number:"cin>>num;if(p=findItem(num)temp=p->Next;p->Next=p->Next->Next;delete temp;cout<<"Deleted successfully!"<<endl<<endl;elsecout<<
20、;"Not found!"<<endl<<endl;save();void StaffChart:save() out.open("StaffChart.txt");for(Staff * p=Head->Next;p!=End;p=p->Next)out<<p->get_num()<<" "<<p->get_name()<<" "<<p->get_age()<<endl;out.close
21、();int StaffChart:findnumber() int n=0; Staff *p=Head->Next; while(p!=NULL) n+; p=p->Next; cout<<"Number of staff:"<<n-1<<endl; return n-1; class SalesmanChartpublic:SalesmanChart();SalesmanChart();void find(); void save(); void modifyItem(); void removeItem(); int
22、findnumber(); void display() for(Salesman *p=Head->Next;p!=End;p=p->Next)p->show_salesman();void addItem() End->set_salesman();End->Next=new Salesman;End=End->Next;save();private:Salesman * Head,* End;ifstream in; ofstream out; Salesman * findItem(char * num)for(Salesman * p=Head;p
23、->Next!=End;p=p->Next)if(!strcmp(p->Next->get_num() ,num)return p;return NULL;SalesmanChart:SalesmanChart() Head=new Salesman;Head->Next=new Salesman;End=Head->Next;in.open("SalesmanChart.txt");while(!in.eof()End->InputFromFile(in);if(End->get_num()0='0')bre
24、ak;End->Next=new Salesman;End=End->Next;in.close();SalesmanChart:SalesmanChart() for(Salesman * temp;Head->Next!=End;)temp=Head->Next;Head->Next=Head->Next->Next;delete temp;delete Head,End;void SalesmanChart:find() char num10;Salesman * p=NULL;cout<<"Please input the
25、 search sales numbers:"cin>>num;if(p=findItem(num)p->Next->show_salesman();elsecout<<"Not found!"<<endl<<endl;void SalesmanChart:modifyItem() char num10;Salesman * p=NULL;cout<<"Please input to modify the sales numbers:"cin>>num;if(p
26、=findItem(num)p->Next->show_salesman();cout<<"Please input the new content:"<<endl;p->Next->set_salesman();elsecout<<"Not found!"<<endl<<endl;save();void SalesmanChart:removeItem() char num10;Salesman *p=NULL,*temp=NULL;cout<<"
27、Please delete sales numbers:"cin>>num;if(p=findItem(num)temp=p->Next;p->Next=p->Next->Next;delete temp;cout<<"Deleted successfully!"<<endl<<endl;elsecout<<"Not found!"<<endl<<endl;save();void SalesmanChart:save() out.open
28、("SalesmanChart.txt");for(Salesman * p=Head->Next;p!=End;p=p->Next)out<<p->get_num()<<p->get_name()<<p->get_age()<<p->get_sales()<<endl;out.close();int SalesmanChart:findnumber() int n=0; Salesman *p=Head->Next; while(p!=NULL) n+; p=p->
29、Next; cout<<"Sales numbers:"<<n-1<<endl; return n-1; class ManagerChartpublic:ManagerChart();ManagerChart();void find(); void save(); void modifyItem(); void removeItem(); int findnumber(); void display() Manager *p=Head->Next;for(p;p!=End;p=p->Next)p->show_manag
30、er();void addItem() End->set_manager();End->Next=new Manager;End=End->Next;save();private:Manager * Head,* End;ifstream in; ofstream out; Manager * findItem(char * num)for(Manager * p=Head;p->Next!=End;p=p->Next)if(!strcmp(p->Next->get_num() ,num)return p;return NULL;ManagerChar
31、t:ManagerChart() Head=new Manager;Head->Next=new Manager;End=Head->Next;in.open("ManagerChart.txt");while(!in.eof()End->InputFromFile(in);if(End->get_num()0='0')break;End->Next=new Manager;End=End->Next;in.close();ManagerChart:ManagerChart() for(Manager * temp;Hea
32、d->Next!=End;)temp=Head->Next;Head->Next=Head->Next->Next;delete temp;delete Head,End;void ManagerChart:find() char num10;Manager * p=NULL;cout<<"Please input the search manager ID:"cin>>num;if(p=findItem(num)p->Next->show_manager();elsecout<<"No
33、t found!"<<endl<<endl;void ManagerChart:modifyItem() char num10;Manager * p=NULL;cout<<"Please input the revision manager ID:"cin>>num;if(p=findItem(num)p->Next->show_manager();cout<<"Please input the new content:"<<endl;p->Next-&
34、gt;set_manager();elsecout<<"Not found!"<<endl<<endl;save();void ManagerChart:removeItem() /刪除條目char num10;Manager *p=NULL,*temp=NULL;cout<<"Please input the deletion manager ID:"cin>>num;if(p=findItem(num)temp=p->Next;p->Next=p->Next->Nex
35、t;delete temp;cout<<"Deleted successfully!"<<endl<<endl;elsecout<<"Not found!"<<endl<<endl;save();void ManagerChart:save() /保存out.open("ManagerChart.txt");for(Manager * p=Head->Next;p!=End;p=p->Next)out<<p->get_num()<
36、;<p->get_name()<<p->get_age()<<p->get_job()<<p->get_dept()<<endl;out.close();int ManagerChart:findnumber() /查看人數(shù) int n=0; Manager *p=Head->Next; while(p!=NULL) n+; p=p->Next; cout<<"Manager number:"<<n-1<<endl; return n-1; clas
37、s SalesManagerChartpublic:SalesManagerChart();SalesManagerChart();void find(); void save(); void modifyItem(); void removeItem(); int findnumber(); void display() SalesManager *p=Head->Next;for(;p!=End;p=p->Next)p->show_salesmanager();void addItem() End->set_salesmanager();End->Next=n
38、ew SalesManager;End=End->Next;save();private:SalesManager * Head,* End;ifstream in; ofstream out; SalesManager * findItem(char * num)for(SalesManager * p=Head;p->Next!=End;p=p->Next)if(!strcmp(p->Next->get_num() ,num)return p;return NULL;SalesManagerChart:SalesManagerChart() Head=new
39、SalesManager;Head->Next=new SalesManager;End=Head->Next;in.open("SalesManagerChart.txt");while(!in.eof()End->InputFromFile(in);if(End->get_num()0='0')break;End->Next=new SalesManager;End=End->Next;in.close();SalesManagerChart:SalesManagerChart() for(SalesManager *
40、 temp;Head->Next!=End;)temp=Head->Next;Head->Next=Head->Next->Next;delete temp;delete Head,End;void SalesManagerChart:find() char num10;SalesManager * p=NULL;cout<<"Please input the search sales manager ID:"cin>>num;if(p=findItem(num)p->Next->show_salesmana
41、ger();elsecout<<"Not found!"<<endl<<endl;void SalesManagerChart:modifyItem() char num10;SalesManager * p=NULL;cout<<"Please input to modify the number of Sales Manager:"cin>>num;if(p=findItem(num)p->Next->show_salesmanager();cout<<"P
42、lease input the new content:"<<endl;p->Next->set_salesmanager();elsecout<<"Not found!"<<endl<<endl;save();void SalesManagerChart:removeItem() char num10;SalesManager *p=NULL,*temp=NULL;cout<<"Please delete sales manager ID:"cin>>num;
43、if(p=findItem(num)temp=p->Next;p->Next=p->Next->Next;delete temp;cout<<"Deleted successfully!"<<endl<<endl;elsecout<<"Not found!"<<endl<<endl;save();void SalesManagerChart:save() out.open("SalesManagerChart.txt");for(Sales
44、Manager * p=Head->Next;p!=End;p=p->Next)out<<p->get_num()<<p->get_name()<<p->get_age()<<p->get_sales()<<p->get_job()<<p->get_dept()<<endl;out.close();int SalesManagerChart:findnumber() int n=0; SalesManager *p=Head->Next; while(p!=
45、NULL) n+; p=p->Next; cout<<"Sales Manager for the number:"<<n-1<<endl; return n-1; int main()int x,y,z;StaffChart Staff_Chart;SalesmanChart Salesman_Chart;ManagerChart Manager_Chart;SalesManagerChart SalesManager_Chart;bool quit=false;while(!quit)cout<<"Sele
46、ct function : n1.the increase of data t2. update data t3.query datat4.delete data t5. for specific categories of personnel t6. show the number of employees t7. exit"<<endl;cin>>x;switch(x)case 1:cout<<"Selection for increased types: n1. employee t2. Sales t3.Manager t4.Sa
47、les Manager"<<endl;cin>>y;switch(y)case 1:Staff_Chart.addItem();break;case 2:Salesman_Chart.addItem();break;case 3:Manager_Chart.addItem();break;case 4:SalesManager_Chart.addItem();break;default :cout<<"Input error, program termination!"<<endl;exit(-1);break;ca
48、se 2:cout<<"Select Update type: n1. employee t2. Sales t3.Manager t4.Sales Manager"<<endl;cin>>y;switch(y)case 1:Staff_Chart.modifyItem();break;case 2:Salesman_Chart.modifyItem();break;case 3:Manager_Chart.modifyItem();break;case 4:SalesManager_Chart.modifyItem();break;de
49、fault :cout<<"Input error, program termination!"<<endl;exit(-1);break;case 3:cout<<"Choose a query type: n1. employee t2. Sales t3.Manager t4.Sales Manager"<<endl;cin>>y;switch(y)case 1:Staff_Chart.find();break;case 2:Salesman_Chart.find();break;case
50、 3:Manager_Chart.find();break;case 4:SalesManager_Chart.find();break;default :cout<<"Input error, program termination!"<<endl;exit(-1);break;case 4:cout<<"Select Delete type:n1. employee t2. Sales t3.Manager t4.Sales Manager"<<endl;cin>>y;switch(y)case 1:Staff_Chart.removeItem();break;case 2:Salesman_Chart.removeItem();break;case 3:Manager_Chart.removeItem();break;case 4:SalesManager_Chart.removeItem();break;default :
溫馨提示
- 1. 本站所有資源如無(wú)特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 獸醫(yī)環(huán)境適應(yīng)性與應(yīng)激管理考核試卷
- 2024年五金材料庫(kù)存管理合同3篇
- 智能轉(zhuǎn)盤分揀機(jī)課程設(shè)計(jì)
- 2024年版商業(yè)地產(chǎn)項(xiàng)目整體轉(zhuǎn)讓合同范本3篇
- 電子測(cè)量?jī)x器的抗干擾技術(shù)考核試卷
- 玉米淀粉在動(dòng)物飼料添加劑中的應(yīng)用考核試卷
- 小班公開課領(lǐng)域課程設(shè)計(jì)
- 無(wú)人便利店課程設(shè)計(jì)
- 《基于結(jié)構(gòu)光視覺的板材壓平矯直建模與方法研究》
- 《古為今用的現(xiàn)代包裝設(shè)計(jì)》
- 火災(zāi)事故中的通風(fēng)與煙氣控制
- 2024年完整離婚協(xié)議書下載-(含多款)
- 蒙牛數(shù)字化 營(yíng)養(yǎng)世界
- 2024年度醫(yī)院燒傷科接診統(tǒng)計(jì)報(bào)告課件
- 《英國(guó)教育》課件
- 人教版2023-2024學(xué)年四年級(jí)數(shù)學(xué)上冊(cè)典型例題系列 第四單元:面積問題專項(xiàng)練習(xí)(解析版)
- W紅茶加工與品質(zhì)形成紅茶加工工藝與品質(zhì)形成w紅茶加工與品質(zhì)形成紅茶加工工藝與品質(zhì)形成
- 【倫理課件】死亡與安樂死
- 腎造瘺護(hù)理查房
- 歷代反腐完整
- 《現(xiàn)代控制理論》(劉豹-唐萬(wàn)生)
評(píng)論
0/150
提交評(píng)論