📄 labour.cpp
字号:
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
#include <graphics.h>
#include <string.h>
#include "labour.h"
#include "lpiece.h"
int LabourWorker::amount=0;
long int LabourWorker::totalM=0;
LabourWorker *LabourWorker::first=0;
LabourWorker *LabourWorker::end=0;
LabourWorker::LabourWorker(const char* pFirst,const char* pLast,float tBonus=0.0)
:Employee(pFirst,pLast)
{
bonus=tBonus;
wages=800;
if(first==0)
first=this;
else
end->next=this;
end=this;
end->next=0;
amount++;
earnings();
}
LabourWorker::LabourWorker(float tBonus=0.0)
:Employee(" "," ")
{
bonus=tBonus;
wages=800;
amount++;
earnings();
}
LabourWorker::~LabourWorker()
{
amount--;
totalM-=salary;
Employee::totalM-=salary;
if(first==this)
first=this->next;
else
for(LabourWorker *p=first;p;p=p->next)
if(p->next==this) p->next=this->next;
}
void LabourWorker::earnings()
{
salary=wages+bonus;
totalM+=salary;
Employee::totalM+=salary;
}
void LabourWorker::setBonus(int tBonus)
{
totalM-=salary;
Employee::totalM-=salary;
bonus=tBonus;
earnings();
}
LabourWorker *LabourWorker::getFirst() const{ return first;}
Employee *LabourWorker::getNext() const{ return next;}
int LabourWorker::getAmount() const{ return amount;}
long int LabourWorker::getTotalM() const{ return totalM;}
int LabourWorker::getSalary() const{ return salary;}
void LabourWorker::delAll()
{
LabourWorker *p;
for(p=p->first;p;p=p->next) delete p;
}
void LabourWorker::printList(int x,int y,int lines)
{
lines=lines/2;
int i=1;
LabourWorker *p;
for (p=p->first;p;p=p->next)
{
cout<<*p;
if(i%lines==0)
{
cout<<endl<<"Press space to continue"<<endl;
while(getch()!=32);
gotoxy(x,y);
setfillstyle(BLACK,COPY_PUT);
bar(0,30,470,458);
}
i++;
}
cout<<endl<<"Press space to continue"<<endl;
while(getch()!=32);
}
void LabourWorker::saveList(ofstream &fout)
{
LabourWorker *p;
LabourAndPiece *pl;
fout<<"Labour: "<<(p->amount-pl->getAmount())<<endl;
for (p=p->first;p;p=p->next)
fout<<p->firstName<<" "<<p->lastName<<" "<<p->bonus<<endl;
}
void LabourWorker::display(ostream &out) const
{
Employee::display(out);
out<<" Labour Worker"<<endl;
out<<"BaseWages: "<<wages<<" Bonus: "<<bonus<<" Salary:"<<setw(6)<<salary<<endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -