⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lpiece.cpp

📁 1、 模拟一间公司(有普通工人、经理、销售员、计时工人和计件工人)的雇员月工资单管理系统
💻 CPP
字号:
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
#include <graphics.h>
#include <string.h>
#include "lpiece.h"

int LabourAndPiece::amount=0;
long int LabourAndPiece::totalM=0;
long int LabourAndPiece::totalMp=0;
long int LabourAndPiece::totalMl=0;
LabourAndPiece *LabourAndPiece::first=0;
LabourAndPiece *LabourAndPiece::end=0;
LabourAndPiece::LabourAndPiece(const char *pFirst,const char *pLast,float tBonus,float tQuantity,char t)
	      :Employee(pFirst,pLast),LabourWorker(tBonus),PieceWorker(tQuantity,t)
{
  amount++;
  if(first==0)
    first=this;
  else
    end->next=this;
  end=this;
  end->next=0;
  earnings();
}

LabourAndPiece::~LabourAndPiece()
{
  amount--;
  if(first==this)
    first=this->next;
  else
    for(LabourAndPiece *p=first;p;p=p->next)
    if(p->next==this) p->next=this->next;
  totalM-=salary;
  totalMp-=PieceWorker::salary;
  totalMl-=LabourWorker::salary;
}

void LabourAndPiece::earnings()
{
  totalMp+=PieceWorker::salary;
  totalMl+=LabourWorker::salary;
  salary=LabourWorker::salary+PieceWorker::salary;
  totalM+=salary;
}

void LabourAndPiece::setType(char tType)
{
  totalMp-=PieceWorker::salary;
  totalMl-=LabourWorker::salary;
  totalM-=salary;
  PieceWorker::setType(tType);
  earnings();
}

void LabourAndPiece::setQuantity(int tQuantity)
{
  totalMp-=PieceWorker::salary;
  totalMl-=LabourWorker::salary;
  totalM-=salary;
  PieceWorker::setQuantity(tQuantity);
  earnings();
}

void LabourAndPiece::setBonus(int tBonus)
{
  totalMp-=PieceWorker::salary;
  totalMl-=LabourWorker::salary;
  totalM-=salary;
  LabourWorker::setBonus(tBonus);
  earnings();
}

LabourAndPiece *LabourAndPiece::getFirst() const{ return first;}

Employee *LabourAndPiece::getNext() const{ return next;}

int LabourAndPiece::getAmount() const{ return amount;}

long int LabourAndPiece::getTotalM() const{ return totalM;}

long int LabourAndPiece::getTotalMp() const{ return totalMp;}

long int LabourAndPiece::getTotalMl() const{ return totalMl;}

int LabourAndPiece::getSalary() const{ return salary;}

void LabourAndPiece::delAll()
{
  LabourAndPiece *p;
  for(p=p->first;p;p=p->next)delete p;
}

void LabourAndPiece::printList(int x,int y,int lines)
{
  int i=1;
  lines/=4;
  LabourAndPiece *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 LabourAndPiece::saveList(ofstream &fout)
{
  LabourAndPiece *p;
  fout<<"LabourAndPiece: "<<p->amount<<endl;
  for (p=p->first;p;p=p->next)
    fout<< p->firstName<<" "<<p->lastName<<" "<<p->bonus<<" "<<p->quantity<<" "<<p->type<<endl;
}

void LabourAndPiece::display(ostream &out) const
{
  Employee::display(out);
  out<<"Labour And Piece Worker"<<endl;
  out<<"BaseWages: "<<wages<<" Bonus: "<<bonus<<endl;
  out<<"Type:"<<type<<" WagesPerPiece: "<<setw(2)<<perPiece<<" Quantity: "<<quantity<<endl;
  out<<"Salary:"<<setw(6)<<getSalary()<<endl;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -