This program models a database of employees of a company. There are three kinds of employees in the company: manager, scientist and laborers. The database stores a name and an employee identification number of all employees, no matter what their category. However, for manager, it also stores their title and golf club dues. For scientists, it stores the number of articles they have published. Laborers need no additional data beyond their names and numbers. All information to be obtained through a member function getdata(). Information about each employee are to displayed through a constant member function putdata(). Define appropriate classes, member functions. Create an array of objects of each employee type (manager, scientist and laborers separately). Your program should able to read information about each employee type and display the same.
#include <iostream>
using namespace std;
struct labourer_data {
string name;
int id;
};
struct scientist_data {
string name;
int id;
int annotations;
};
struct manager_data {
string name;
int id;
string title;
double due;
};
class Labourer {
private:
string name;
int id;
public:
Labourer(string name, int id) {
this->name = name;
this->id = id;
}
void put_data() {
cout << "{name: " << this->name << ", id: " << this->id << "}" << endl;
}
struct labourer_data get_data() {
return {name, id};
}
};
class Scientist {
private:
string name;
int id;
int annotations;
public:
Scientist(string name, int id, int annotations) {
this->name = name;
this->id = id;
this->annotations = annotations;
}
void put_data() {
cout << "{name: " << this->name << ", id: " << this->id << ", annotations: " << this->annotations << "}" << endl;
}
struct scientist_data get_data() {
return {name, id, annotations};
}
};
class Manager {
private:
string name;
int id;
string title;
double due;
public:
Manager(string name, int id, string title, double due) {
this->name = name;
this->id = id;
this->title = title;
this->due = due;
}
void put_data() {
cout << "{name: " << this->name << ", id: " << this->id << ", title: " << this->title << ", due: " << this->due << "}" << endl;
}
struct manager_data get_data() {
return {name, id, title, due};
}
};
int main() {
Labourer *l = new Labourer("John", 34);
l->put_data();
Scientist *s = new Scientist("Bob", 34, 435);
s->put_data();
Manager *m = new Manager("Monky", 3345, "Horse", 435.34);
m->put_data();
return 0;
}
Comments
Leave a comment