版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、#include <iostream.h>#include <fstream.h>#include <ctype.h>#include <string.h>/全局?jǐn)?shù)據(jù),對(duì)象double ManagerSalary=5000; /經(jīng)理固定月薪double SalesManagerSalary=2000; /銷售經(jīng)理固定月薪double SalesManagerPercent=0.5; /銷售經(jīng)理提成double SalesPercent=5; /銷售人員提成double WagePerHour=20; /技術(shù)人員小時(shí)工資int ID; /員工標(biāo)識(shí)(
2、要保證唯一)class Person /員工類protected: int No; /編號(hào) char Name20; /姓名 int Duty; /崗位 double Earning; /收入 Person *next;public: Person(char ID,char *Name,int Duty) this->Duty=Duty; strcpy(this->Name,Name); this->No=ID; virtual void CalcSalary()=0; virtual void Output()=0; friend class Company;class M
3、anager:public Person /經(jīng)理類public: Manager(char ID,char *Name,int Duty):Person(ID,Name,Duty) void CalcSalary()Earning=ManagerSalary; void Output() CalcSalary(); cout<<No<<"t"<<Name<<"t經(jīng)理t"<<Earning<<endl;class SalesManager:public Person /銷售經(jīng)理類pri
4、vate: double Amounts;public: SalesManager(char ID,char *Name,int Duty,double Amounts):Person(ID,Name,Duty)this->Amounts=Amounts; void SetAmounts(double s) Amounts=s; void CalcSalary() Earning=SalesManagerSalary+Amounts*SalesManagerPercent/100; void Output() CalcSalary(); cout<<No<<&qu
5、ot;t"<<Name<<"t銷售經(jīng)理t"<<Earning<<endl;class Technician:public Person /技術(shù)員類private: double t;public: Technician(char ID,char *Name,int Duty,double T):Person(ID,Name,Duty) this->t=T; double GetT() return t; void SetT(double T) this->t=T; void CalcSalary() Ea
6、rning=WagePerHour*t; void Output() CalcSalary(); cout<<No<<"t"<<Name<<"t技術(shù)員t"<<t<<"t"<<Earning<<endl;class Sales:public Person /銷售員類private: double Amount;public: Sales(char ID,char *Name,int Duty,double Amount):Person(ID,
7、Name,Duty) this->Amount=Amount; double GetAmount() return Amount; void SetAmount(double Amount) this->Amount=Amount; void CalcSalary() Earning=SalesPercent/100*Amount; void Output() CalcSalary(); cout<<No<<"t"<<Name<<"t銷售員t"<<Amount<<&quo
8、t;t"<<Earning<<endl;class Company /公司類private: Person *Worker; /員工表public: Company() Worker=0; Company() Person *p; p=Worker; while(p) p=p->next; delete Worker; Worker=p; Worker=0; void Add(); /增加人員 void Delete(); /刪除人員 void Modify(); /修改人員 void Query(); /查詢?nèi)藛T void Set();/設(shè)置基本數(shù)據(jù)
9、void Save(); /數(shù)據(jù)存盤(包括基礎(chǔ)數(shù)據(jù),人員數(shù)據(jù));void Company:Add() Person *p; /新結(jié)點(diǎn)指針 int Duty; char Name20; double Amount,Amounts,T; cout<<"n* 新增員工 *n" /輸入員工信息 ID+; cout<<"輸入崗位(1-經(jīng)理2-銷售經(jīng)理3-銷售員4-技術(shù)員):" cin>>Duty; cout<<"輸入姓名:" cin>>Name;if(Duty=2)cout<&l
10、t;"本月銷售額:" cin>>Amounts;if(Duty=3) cout<<"本月銷售額:" cin>>Amount;else if(Duty=4) cout<<"本月工作小時(shí)數(shù)(0-168):" cin>>T;/創(chuàng)建新員工結(jié)點(diǎn)switch(Duty)case 1:p=new Manager(ID,Name,Duty); break;case 2:p=new SalesManager(ID,Name,Duty,Amounts); break;case 3:p=new S
11、ales(ID,Name,Duty,Amount); break;case 4:p=new Technician(ID,Name,Duty,T); break;p->next=0;/員工結(jié)點(diǎn)加入鏈表if(Worker) /若已經(jīng)存在結(jié)點(diǎn)Person *p2;p2=Worker;while(p2->next) /查找尾結(jié)點(diǎn)p2=p2->next;p2->next=p; /連接else /若不存在結(jié)點(diǎn)(表空)Worker=p; /連接 void Company:Delete() /刪除人員 int No; cout<<"n* 刪除員工 *n"
12、 cout<<"ID:" cin>>No;/查找要?jiǎng)h除的結(jié)點(diǎn) Person *p1,*p2; p1=Worker; while(p1) if(p1->No=No) break; else p2=p1; p1=p1->next;/刪除結(jié)點(diǎn) if(p1!=NULL)/若找到結(jié)點(diǎn),則刪除 if(p1=Worker) /若要?jiǎng)h除的結(jié)點(diǎn)是第一個(gè)結(jié)點(diǎn) Worker=p1->next; delete p1; else /若要?jiǎng)h除的結(jié)點(diǎn)是后續(xù)結(jié)點(diǎn) p2->next=p1->next; delete p1; cout<<&qu
13、ot;找到并刪除n" else /未找到結(jié)點(diǎn) cout<<"未找到!n"char ch; cout<<"按任意鍵返回菜單:" cin>>ch; if(ch!='0') return ; void Company:Modify() int No,Duty; char Name20; double Amount,Amounts,T; cout<<"n* 修改員工 *n"cout<<"ID:" cin>>No;/查找要修改的
14、結(jié)點(diǎn) Person *p1,*p2; p1=Worker; while(p1) if(p1->No=No) break; else p2=p1; p1=p1->next;/修改結(jié)點(diǎn) if(p1!=NULL)/若找到結(jié)點(diǎn) p1->Output(); cout<<"調(diào)整崗位(1-經(jīng)理2-銷售經(jīng)理3-銷售員4-技術(shù)員):" cin>>Duty; if(p1->Duty!=Duty) /若崗位發(fā)生變動(dòng) /修改其它數(shù)據(jù) cout<<"輸入姓名:" cin>>Name; if(Duty=2) c
15、out<<"本月銷售額:" cin>>Amounts; if(Duty=3) cout<<"本月銷售額:" cin>>Amount; else if(Duty=4) cout<<"本月工作小時(shí)數(shù)(0-168):" cin>>T;/創(chuàng)建新員工結(jié)點(diǎn) Person *p3; switch(Duty) case 1:p3=new Manager(p1->No,Name,Duty); break; case 2:p3=new SalesManager(p1->N
16、o,Name,Duty,Amounts); break; case 3:p3=new Sales(p1->No,Name,Duty,Amount); break; case 4:p3=new Technician(p1->No,Name,Duty,T); break;/員工結(jié)點(diǎn)替換到鏈表 p3->next=p1->next; if(p1=Worker) /若要替換的結(jié)點(diǎn)是第一個(gè)結(jié)點(diǎn) Worker=p3; else /若要?jiǎng)h除的結(jié)點(diǎn)是后續(xù)結(jié)點(diǎn) p2->next=p3;/刪除原來的員工結(jié)點(diǎn) delete p1; else /若崗位沒有變動(dòng) cout<<&q
17、uot;輸入姓名:" cin>>p1->Name; if(Duty=3) cout<<"本月銷售額:"cin>>Amount; (Sales *)p1)->SetAmount(Amount); else if(Duty=4) cout<<"本月工作小時(shí)數(shù)(0-168):"cin>>T; (Technician *)p1)->SetT(T); cout<<"修改成功!n"else /未找到結(jié)點(diǎn)cout<<"未找到要查
18、詢的人員!n" char ch;cout<<"按任意鍵返回菜單:"cin>>ch;if(ch!='0')return ;void Company:Query()int i;Person *p1,*p2;p1=Worker;if(p1)cout<<"請(qǐng)輸入要查找的人的編號(hào):"cin>>i;while(p1)if(p1->No=i)break;elsep2=p1;p1=p1->next;if(p1!=NULL)p1->Output();elsechar ch;cout
19、<<"查無此人,按任意鍵返回菜單:"cin>>ch;if(ch!='0')return ;elsecout<<"系統(tǒng)還未存入人員"<<endl;return ;void Company:Set() cout<<"n* 設(shè)置基礎(chǔ)數(shù)據(jù) *n" cout<<"經(jīng)理固定月薪"<<ManagerSalary<<"元:" cin>>ManagerSalary; cout<<
20、"銷售經(jīng)理固定月薪"<<SalesManagerSalary<<"元:" cin>>SalesManagerSalary; cout<<"銷售經(jīng)理提成"<<SalesManagerPercent<<":" cin>>SalesManagerPercent; cout<<"銷售人員提成"<<SalesPercent<<":" cin>>SalesP
21、ercent; cout<<"技術(shù)人員小時(shí)工資"<<WagePerHour<<"(元/小時(shí)):" cin>>WagePerHour; cout<<"員工標(biāo)識(shí)>="<<ID<<":" cin>>ID;void Company:Save() /數(shù)據(jù)存盤(包括基礎(chǔ)數(shù)據(jù),人員數(shù)據(jù)),均采用文本文件 ofstream fPerson,fBase; char c; cout<<"n保存人員和基礎(chǔ)數(shù)據(jù),是否
22、繼續(xù)?Y/N:" cin>>c; if(toupper(c)!='Y')return;/保存人員編號(hào)、姓名、崗位 fPerson.open("person.txt",ios:out); Person *p=Worker; while(p) fPerson<<p->No<<"t"<<p->Name<<"t"<<p->Duty<<"t" if(p->Duty=3) fPerson<
23、<(Sales*)p)->GetAmount()<<"t" else if(p->Duty=4) fPerson<<(Technician *)p)->GetT()<<"t" fPerson<<endl; p=p->next; fPerson.close();/保存基礎(chǔ)數(shù)據(jù) fBase.open("base.txt",ios:out); fBase<<"經(jīng)理固定月薪t"<<ManagerSalary<<
24、endl; fBase<<"銷售經(jīng)理固定月薪t"<<SalesManagerSalary<<endl; fBase<<"銷售經(jīng)理提成t"<<SalesManagerPercent<<endl; fBase<<"銷售人員提成t"<<SalesPercent<<endl; fBase<<"技術(shù)人員小時(shí)工資t"<<WagePerHour<<endl; fBase<<"IDt"<<ID<<endl; fPerson.close(); cout<<"n保存人員和基礎(chǔ)數(shù)據(jù)已經(jīng)完成.n"void main()int c;Company a;docout<<" * "<<endl;cout<<" * * "<<en
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 課題申報(bào)參考:閩派古琴的歷史、現(xiàn)狀及文獻(xiàn)研究
- 課題申報(bào)參考:面向?qū)W生創(chuàng)造力培育的場(chǎng)館學(xué)習(xí)環(huán)境測(cè)評(píng)體系與優(yōu)化機(jī)制研究
- 課題申報(bào)參考:面向產(chǎn)品個(gè)性化定制的共享制造資源協(xié)同調(diào)度優(yōu)化理論研究
- 二零二五年度智能電網(wǎng)信息化系統(tǒng)運(yùn)維與電力市場(chǎng)服務(wù)合同3篇
- 二零二五年度黨政機(jī)關(guān)會(huì)議酒店住宿及會(huì)議場(chǎng)地租賃合同4篇
- 2025年度土地承包經(jīng)營權(quán)續(xù)包合同示范文本4篇
- 2025年度個(gè)人個(gè)人房產(chǎn)買賣合同(含裝修及配套設(shè)施)2篇
- 2025年度鋼材行業(yè)投資合作開發(fā)合同
- 2025年個(gè)人購房合同(含房屋保險(xiǎn)服務(wù))
- 二零二五版南京房地產(chǎn)抵押物拍賣合同4篇
- 2024中考復(fù)習(xí)必背初中英語單詞詞匯表(蘇教譯林版)
- 海員的營養(yǎng)-1315醫(yī)學(xué)營養(yǎng)霍建穎等講解
- 《現(xiàn)代根管治療術(shù)》課件
- 肩袖損傷的護(hù)理查房課件
- 2023屆北京市順義區(qū)高三二模數(shù)學(xué)試卷
- 公司差旅費(fèi)報(bào)銷單
- 我國全科醫(yī)生培訓(xùn)模式
- 2021年上海市楊浦區(qū)初三一模語文試卷及參考答案(精校word打印版)
- 八年級(jí)上冊(cè)英語完形填空、閱讀理解100題含參考答案
- 八年級(jí)物理下冊(cè)功率課件
- DBJ51-T 188-2022 預(yù)拌流態(tài)固化土工程應(yīng)用技術(shù)標(biāo)準(zhǔn)
評(píng)論
0/150
提交評(píng)論