第一课作业。
This commit is contained in:
13
OOP/01/Optional01/employee.h
Normal file
13
OOP/01/Optional01/employee.h
Normal file
@@ -0,0 +1,13 @@
|
||||
class Employee {
|
||||
private:
|
||||
int individualEmpNo;
|
||||
int grade;
|
||||
int accumPay;
|
||||
|
||||
public:
|
||||
void getInfo();
|
||||
void init(int, int, int);
|
||||
void setEmpNo(int);
|
||||
void setGrade(int);
|
||||
void setAccumPay(int);
|
||||
};
|
||||
35
OOP/01/Optional01/main.cpp
Normal file
35
OOP/01/Optional01/main.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <iostream>
|
||||
#include "employee.h"
|
||||
|
||||
void Employee::getInfo() {
|
||||
std::cout << "Employee No. " << this->individualEmpNo << ": grade " << this->grade << ", accumPay: " << this->accumPay << std::endl;
|
||||
}
|
||||
|
||||
void Employee::init(int number, int grade, int accumPay) {
|
||||
this->individualEmpNo = number;
|
||||
this->grade = grade;
|
||||
this->accumPay = accumPay;
|
||||
}
|
||||
|
||||
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[4];
|
||||
staff[0].init(1, 1, 30);
|
||||
staff[1].init(2, 2, 60);
|
||||
staff[2].init(3, 4, 120);
|
||||
staff[3].init(5, 5, 150);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
staff[i].getInfo();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user