forked from natto1784/ooplab
88
lab5/14.cpp
Normal file
88
lab5/14.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
class BasicInfo {
|
||||
private:
|
||||
char name[30];
|
||||
int empId;
|
||||
char gender;
|
||||
|
||||
public:
|
||||
void getData();
|
||||
void putData();
|
||||
};
|
||||
|
||||
void BasicInfo::getData() {
|
||||
cout << "Name: ";
|
||||
cin >> name;
|
||||
cout << "Employee ID: ";
|
||||
cin >> empId;
|
||||
cout << "Gender: ";
|
||||
cin >> gender;
|
||||
}
|
||||
|
||||
void BasicInfo::putData() {
|
||||
cout << "Name: " << name << endl
|
||||
<< "Employee ID: " << empId << endl
|
||||
<< "Gender: " << gender << endl;
|
||||
}
|
||||
|
||||
class DeptInfo : public BasicInfo {
|
||||
private:
|
||||
char deptName[30];
|
||||
char assignWork[30];
|
||||
int timeToComplete;
|
||||
|
||||
public:
|
||||
void getData();
|
||||
void putData();
|
||||
};
|
||||
|
||||
void DeptInfo::getData() {
|
||||
BasicInfo::getData();
|
||||
cout << "Name of Department: ";
|
||||
cin >> deptName;
|
||||
cout << "Assigned Work: ";
|
||||
cin >> assignWork;
|
||||
cout << "Time to complete: ";
|
||||
cin >> timeToComplete;
|
||||
}
|
||||
|
||||
void DeptInfo::putData() {
|
||||
BasicInfo::putData();
|
||||
cout << "Name of Department: " << deptName << endl
|
||||
<< "Assigned Work: " << assignWork << endl
|
||||
<< "Time to complete: " << timeToComplete << endl;
|
||||
}
|
||||
|
||||
class EmployeeInfo : public DeptInfo {
|
||||
private:
|
||||
int salary;
|
||||
int age;
|
||||
|
||||
public:
|
||||
void getData();
|
||||
void putData();
|
||||
};
|
||||
|
||||
void EmployeeInfo::getData() {
|
||||
DeptInfo::getData();
|
||||
cout << "Salary of employee: ";
|
||||
cin >> salary;
|
||||
cout << "Age of employee: ";
|
||||
cin >> age;
|
||||
}
|
||||
|
||||
void EmployeeInfo::putData() {
|
||||
DeptInfo::putData();
|
||||
cout << "Salary of employee: " << salary << endl
|
||||
<< "Age of employee: " << age << endl;
|
||||
}
|
||||
|
||||
int main() {
|
||||
EmployeeInfo e;
|
||||
e.getData();
|
||||
e.putData();
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user