2017.11.30李锦浩【第51天】
今天继续学习了类的虚函数以及多态性,感觉到了C++语言对于软件开发的多元化和灵活性。另外我还制作了一个书后的习题,由于太过于复杂,因此只做了一部分,另外一部分需要明天完成。还要今天还阅读了算法导论的关于对于数字的一种简便排列方式,在今天的程序中要需要用到,因此我明天首先需要根据算法导论将数字排列方式的程序编写完成,在完成今天程序的剩余部分。
附:
#include<iostream>
using namespace std;
class alldata
{
public:
personaldata*datahead=NULL;
int number;
};
class salarys
{
public:
virtual voidpayrollaccounting() = 0;
int basicsalary;
};
class personaldata:public salarys
{
public:
char name[100];
unsigned int id;
unsigned int phone;
int positon;
personaldata*next;
int salary;
};
class teacher:public personaldata,virtual public salarys
{
public:
teacher()
{
subsidyteacher = 10;
subsidyprofessor = 30;
associateprofessor = 20;
classhour = 50;
}
void input();
void payrollaccounting();
private:
int subsidyteacher;
int subsidyprofessor;
int associateprofessor;
int classhour;
int absentclass;
int lefthour;
};
class manager:public personaldata
{
public:
manager()
{
jjobsalary = 1000;
}
void payrollaccounting();
private:
int jjobsalary;
};
class lab:public personaldata
{
public:
lab()
{
subsidylab = 20;
workhour = 50;
}
void payrollaccounting();
private:
int subsidylab;
int workhour;
int absenthour;
int lefthuor;
};
void teacher::input()
{
cout << "请输入教师请假课时:";
cin >> absentclass;
lefthour = classhour - absentclass;
cout << "该教师工作课时为:";
}
void teacher::payrollaccounting()
{
input();
if (positon == 1)
salary =lefthour*subsidyteacher + salarys::basicsalary;
if (positon == 2)
salary =lefthour*subsidyprofessor + salarys::basicsalary;
if (positon == 1)
salary =lefthour*associateprofessor + salarys::basicsalary;
}
void manager::payrollaccounting()
{
salary = basicsalary + jjobsalary;
}
void lab::payrollaccounting()
{
cout << "请输入实验员请假时间:";
cin >> absenthour;
lefthuor = workhour - absenthour;
salary = basicsalary +lefthuor*subsidylab;
}
void list( alldata*&datahead)
{
cout << "请输入总人数:";
cin >> datahead->number;
personaldata*s, *p;
for (int i = 0; i < datahead->number; i++)
{
cout << "请输入该教师职位,1表示普通教师,2表示教授,3表示副教授,4表示实验员,5表示管理人员";
cin >> s->positon;
if (s->positon < 4)
{
s = new teacher;
p = new teacher;
s->payrollaccounting();
}
if (s->positon == 4)
{
s = new lab;
p = new lab;
s->payrollaccounting();
}
if(s->positon==5)
{
s = new manager;
p = new manager;
s->payrollaccounting();
}
cout << "请输入教师姓名:";
cin >> s->name;
cout << "请输入教师ID:";
cin >> s->id;
cout << "请输入教师电话号码:";
cin >> s->phone;
if (datahead->datahead == NULL)
{
datahead->datahead = s;
p->next = s;
p = p->next;
}
else
{
p->next = s;
p = p->next;
}
}
s = NULL;
p = NULL;
delete s;
delete p;
}
明日任务:完成算法导论的第一个程序,随后完成今天的程序。