Files
BasicsOfComputerSoftwareEng…/OOP/EmployeeAdmin/main.cpp
2023-03-08 20:54:29 +08:00

55 lines
1.1 KiB
C++

#include "employee.h"
#include <iostream>
int Employee::empCount = 0;
Employee::Employee() {
Employee::empCount++;
this->individualEmpNo = empCount;
this->grade = 0;
this->accumPay = 0;
}
Employee::Employee(int newGrade, int newAccumPay) {
Employee::empCount++;
this->individualEmpNo = Employee::empCount;
this->grade = newGrade;
this->accumPay = newAccumPay;
}
Employee::~Employee() {
std::cout << "欢迎使用,再见" << std::endl;
}
void Employee::printInfo() {
std::cout << "Employee No. " << this->individualEmpNo << ": grade "
<< this->grade << ", accumPay: " << this->accumPay << std::endl;
}
void Employee::setEmpNo(int newNo) {
this->individualEmpNo = newNo;
}
void Employee::setGrade(int newGrade) {
this->grade = newGrade;
}
void Employee::setAccumPay(int newAccumPay) {
this->accumPay = newAccumPay;
}
int main() {
Employee staff[20];
for (int i = 0; i < 20; i++) {
staff[i].setGrade(i + 1);
staff[i].setAccumPay((i + 1) * 10);
}
for (int i = 0; i < 20; i++) {
staff[i].printInfo();
}
return 0;
}