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

📄 11.cpp

📁 题目:高校职工工资管理系统 使用Vc
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include <fstream.h>
#include <string.h>
#include <iostream.h>
#include <stdlib.h>
class Person{  //人员类(抽象类)
protected:
  int No;         //编号
  char Name[20];  //姓名
  int Age;        //年龄
  int Duty;                     //人员类别标志(0-教师,1-实验员,2-行政人员,3-后勤人员,4-外骋人员)
  double Salary;     //基本工资
  Person *next;            //指针域

public:
  Person()  //基类构造
  {
    next=0;  //指针域设置为空
  }
  virtual ~Person()  //基类虚析构
  {
  }
  virtual void Input()=0;                //从键盘输入数据
  virtual void Input(ifstream& ifs)=0;   //从文件输入数据
  virtual void Output()=0;               //向屏幕输出数据
  virtual void Output(ofstream& ofs)=0;  //向文件输出数据
  virtual double Incoming()=0;           //计算收入

  friend class College;
};



class Teacher:virtual public Person  //教师类
{
protected:
  int Hours;  //教师课时

public:  
  //为对象设置数据分为两种途径,通过1)构造函数,2)一般成员函数
  //分开可以使得程序中应用更加灵活
  //本程序采用:缺省构造+Input()
  Teacher()  //构造函数,初始化部分数据
  {
         Duty=1;  
    Salary=1800;
  }

  void Input()  //键盘补充输入其它数据
  {
	  //Person::Input();
	  cout<<"\t\t                    工作证号:";    
	  cin>>No;
	  cout<<"\t\t                    姓名:";
	  cin>>Name;
	  cout<<"\t\t                    年龄:";
	  cin>>Age;  
	  cout<<"\t\t                    教师上学期课时:";   
	  cin>>Hours;
  } 

  void Input(ifstream& ifs)
  {
    ifs>>No>>Name>>Age>>Duty>>Hours;
  } 

  void Output()
  {
	 
    cout<<"\t\t                    教师类职员的信息:"<<endl;
	cout<<"\t\t                    工作证号:"<<No<<endl;
	cout<<"\t\t                    姓名:"<<Name<<endl;
	cout<<"\t\t                    年龄:"<<Age<<endl;
	cout<<"\t\t                    岗位:"<<Duty<<endl;
    cout<<"\t\t                    工作时间:"<<Hours<<endl;
	cout<<"\t\t                    收入:"<<Incoming()<<endl<<endl;
   
  }

  void Output(ofstream& ofs)
  {
	 /* ofs<<"\t\t                    教师类职员的信息:"<<endl;
	  ofs<<"\t\t                    工作证号:"<<No<<endl;
	  ofs<<"\t\t                    姓名:"<<Name<<endl;
	  ofs<<"\t\t                    年龄:"<<Age<<endl;
	  ofs<<"\t\t                    岗位:"<<Duty<<endl;
	  ofs<<"\t\t                    工作时间:"<<Hours<<endl;
	  //ofs<<"\t\t                    "<<endl<<endl;
    */
	   ofs<<No<<"\t"<<Name<<"\t"<<Age<<"\t"<<Duty<<"\t"<<Hours<<"\t"<<endl;
  }

  double Incoming()
  {
    return Salary+(Hours-120)*20;
  }
};

class Assistant:virtual public Person  //实验员
{
protected:
  int Allowance;
  int Hours;

public:
  Assistant()
  {
         Duty=2;    
    Salary=650;
    Allowance=500;
  }
  
  void Input()
  {
	 //Person::Input();
	  cout<<"\t\t                    工作证号:";    
	  cin>>No;
	  cout<<"\t\t                    姓名:";
	  cin>>Name;
	  cout<<"\t\t                    年龄:";
	  cin>>Age;  	
      cout<<"\t\t                    实验员上学期实验课时:";  
	  cin>>Hours;
  }

  void Input(ifstream& ifs)  
  {
    ifs>>No>>Name>>Age>>Duty>>Hours>>Allowance;
  } 

  void Output()
  {
	  cout<<"\t\t                    实验员类职员的信息:"<<endl;
	  cout<<"\t\t                    工作证号:"<<No<<endl;
	  cout<<"\t\t                    姓名:"<<Name<<endl;
	  cout<<"\t\t                    年龄:"<<Age<<endl;
	  cout<<"\t\t                    岗位:"<<Duty<<endl;
	  cout<<"\t\t                    工作时间:"<<Hours<<endl;
	  cout<<"\t\t                    津贴:"<<Allowance<<endl;
 	  cout<<"\t\t                    收入:"<<Incoming()<<endl<<endl;
    
  }

  void Output(ofstream& ofs)
  {
	 
      ofs<<No<<"\t"<<Name<<"\t"<<Age<<"\t"<<Duty<<"\t"<<Hours<<"\t"<<Allowance<<"\t"<<endl;
  }

  double Incoming()
  {

    return Salary+Allowance+(Hours-70)*20;
  }
};

class Manager:virtual public Person  //行政人员
{
protected:
  int Allowance;

public:
  Manager()
  {
        Duty=3;
    Salary=1750;
    Allowance=750;
  }

  void Input()
  {
	  //Person::Input();
	  cout<<"\t\t                    工作证号:";    
	  cin>>No;
	  cout<<"\t\t                    姓名:";
	  cin>>Name;
	  cout<<"\t\t                    年龄:";
	  cin>>Age;
		
   
  }

  void Input(ifstream& ifs)  
  {
    ifs>>No>>Name>>Age>>Duty>>Allowance;
  } 

  void Output()
  {
	  cout<<"\t\t                    行政人员类职员的信息:"<<endl;
	  cout<<"\t\t                    工作证号:"<<No<<endl;
	  cout<<"\t\t                    姓名:"<<Name<<endl;
	  cout<<"\t\t                    年龄:"<<Age<<endl;
	  cout<<"\t\t                    岗位:"<<Duty<<endl;
	  cout<<"\t\t                    津贴:"<<Allowance<<endl;
 	  cout<<"\t\t                    收入:"<<Incoming()<<endl<<endl;
      
  }

  void Output(ofstream& ofs)
  {
	 
	  ofs<<No<<"\t"<<Name<<"\t"<<Age<<"\t"<<Duty<<"\t"<<Allowance<<"\t"<<endl;
     
  }

  double Incoming()
  {
    return Salary+Allowance;
  }
};

class Logistic:public Teacher,public Assistant //后勤人员
{
      int Allowance;
public:
  Logistic()
  {
         Duty=4;
    Teacher::Salary=800;
  }
  void Input()
  {
	  //Person::Input();
	  cout<<"\t\t                    工作证号:";    
	  cin>>No;
	  cout<<"\t\t                    姓名:";
	  cin>>Name;
	  cout<<"\t\t                    年龄:";
	  cin>>Age;
      cout<<"\t\t                    后勤人员的补助:"; 
	  cin>>Allowance;
  }

  void Input(ifstream& ifs)  
  {
    ifs>>No>>Name>>Age>>Duty>>Allowance;
  } 

  void Output()
  {
	  cout<<"\t\t                    后勤人员类职员的信息:"<<endl;
	  cout<<"\t\t                    工作证号:"<<No<<endl;
	  cout<<"\t\t                    姓名:"<<Name<<endl;
	  cout<<"\t\t                    年龄:"<<Age<<endl;
	  cout<<"\t\t                    岗位:"<<Duty<<endl;
	  cout<<"\t\t                    津贴:"<<Allowance<<endl;
 	  cout<<"\t\t                    收入:"<<Incoming()<<endl<<endl;
   
  }

  void Output(ofstream& ofs)
  {
	
     ofs<<No<<"\t"<<Name<<"\t"<<Age<<"\t"<<Duty<<"\t"<<Allowance<<"\t"<<endl;  
  }

  double Incoming()
  {
    return Salary+Allowance;
  }
};

class Invitation:public Teacher //外骋人员
{

char Rank[30];
public:
  Invitation()
  {
         Duty=5;
  int Salary=1650;
  }

  void Input()
  {
	  //Person::Input();
	  cout<<"\t\t                    工作证号:";    
	  cin>>No;
	  cout<<"\t\t                    姓名:";
	  cin>>Name;
	  cout<<"\t\t                    年龄:";
	  cin>>Age;	
      cout<<"\t\t                    外骋人员上学期课时:"; 
	  cin>>Hours;
      cout<<"\t\t                    外骋人员的等级(教授、副教授、讲师、助教):"; 
	  cin>>Rank;
//	  professor associate/ professor/ instructor/assistant professor 
  }

  void Input(ifstream& ifs)  
  {
    ifs>>No>>Name>>Age>>Duty>>Hours>>Rank;
  } 

  void Output(ofstream& ofs)
  {

	  ofs<<No<<"\t"<<Name<<"\t"<<Age<<"\t"<<Duty<<"\t"<<Hours<<"\t"<<Rank<<"\t"<<endl;  
	  
  }
  
  void Output()
  {
	  cout<<"\t\t                    外骋人员类职员的信息:"<<endl;
	  cout<<"\t\t                    工作证号:"<<No<<endl;
	  cout<<"\t\t                    姓名:"<<Name<<endl;
	  cout<<"\t\t                    年龄:"<<Age<<endl;
	  cout<<"\t\t                    岗位:"<<Duty<<endl;
	  cout<<"\t\t                    级别:"<<Rank<<endl;
 	  cout<<"\t\t                    收入:"<<Incoming()<<endl<<endl;
  
  }

  double Incoming()
  {
	
    return Salary+Hours*20;
  }
};
class College
{
private:
  Person *PL;
  void Clear();
  int College::Find(int ID,Person **p1,Person **p2);
  int College::Find1( char *NAME,Person **p1,Person **p2);
public:
  College();      //构造
  ~College();     //析构
  void Add();     //增加职工
  void Delete();  //删除职工
  void Modify();  //修改职工
  void Print();   //输出职工信息
  void Save();    //职工信息存盘
  void Load();    //职工信息装入
  void Salary();  //输出职工工资
  void Interface();
  void Interface1();
  void Interface2();
  void Interface3();
};

College::College()  //构造函数(创建1个头结点的链表)
{
  Person *p=new Teacher;
  PL=p;
  Load();
}

College::~College() //析构函数(仅保留1个头结点)
{
  Person *p=PL;
  while(p)  //逐个删除结点,包括头结点
  {
    PL=p->next;
    delete p;
    p=PL;
  }
  PL=0;
}

void College::Add()  //增加职工

⌨️ 快捷键说明

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