Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. (The Person, Student, Employee, Faculty, and Staff classes) Design a class na

ID: 3605490 • Letter: 2

Question

2. (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person and its two derived classes named Student and Employee. Make Faculty and Staff derived classes of Employee. A person has a name, address, phone number, and email address. A student has a class status freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date hired. Use the MyDate class defined in Programming Exercise 1 to create an object for date hired. A faculty member has office hours and a rank. A staff member has a title. Define a constant virtual tostring function in the Person class and override it in each class to display the class name and the person's name. Draw the UML diagram for the classes and implement them. Write a test program that creates a Person, Student, Employee, Faculty, and Staff, and invokes their tostring() functions.

Explanation / Answer

Note: Have to write the Main function() and toString function impleemnation..I will do it...

________________

#include <iostream>

using namespace std;

class Person

{

private :

string name, address;

string phoneno,email;

public :

// Zero Argument Constructor

Person() {

super();

}

Person(string name, string address,string phoneno,string email) {

super();

this->name = name;

this->address = address;

this->phoneno=phoneno;

this->email=email;

}

  

string getName() {

return name;

}

void setName(string name) {

this.name = name;

}

string getAddress() {

return address;

}

void setAddress(string address) {

this.address = address;

}

  

virtual string toString();

};

class Student:public Person

{

private :

const string classStatus;

public :

public Student(string name, string address,string phoneno,string email, string classStatus):Person(name,address,phoneno,email)

{

this->classStatus = classStatus;

}

public string toString() {

  

}

};

class Employee:public Person

{

private :

string office;

double salary;

MyDate date;

public :

Employee(string name, string address,string phoneno,string email,string office,double salary,MyDate date):Person(name,address,phoneno,email)

{

this->office=office;

this->salary=salary;

this->date=date;   

}

  

// Setters and getters

string getOffice() {

return office;

}

void setOffice(string office) {

this->office = office;

}

double getSalary() {

return salary;

}

void setSalary(double salary) {

this->salary = salary;

}

string toString() {

  

}

};

class Staff:public Employee

{

private :

string title;

public :

//Parameterized constructor.

public Staff(string name, string address,string phoneno,string email,string office,double salary,MyDate date,string title):Employee(string name, string address,string phoneno,string email,string office,double salary,MyDate date)

{

this.title = title;

}

//Setters and getters

string getTitle() {

return title;

}

svoid setTitle(string title) {

this.title = title;

}

string toString() {

}

class Faculty:public Employee

{

private :

int office_hours;

public :

Faculty(string name, string address,string phoneno,string email,string office,double salary,MyDate date,int office_hours):Employee(string name, string address,string phoneno,string email,string office,double salary,MyDate date)

{

this->office_hours=office_hours;

}

//Setters and getters

int getOffice_hours() {

return office_hours;

}

void setOffice_hours(int office_hours) {

this->office_hours = office_hours;

}

string toString() {

}

};

};

int main()

{

  

return 0;

}

_________________