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

SOLVE USING C++ 1.(100 points) Design a class named Employee. Design two child c

ID: 3718010 • Letter: S

Question

SOLVE USING C++

1.(100 points) Design a class named Employee. Design two child classes of Employee named Faculty and Staff. The UML diagram for the three classes is as follows (only their own members are listed for the Faculty and Staff classes. You should determine the access specifications needed to access any parent class members and methods. Employee name : String -office: String -salary: int phoneNumber: String email: String + Employee (name: String, phoneNumber. String. email: String, office: Sting, salarv. int) + Employee (office: String, salary. int) +Employee0 +getOfficeO: String +setOffice(office: Sting): void +getSalary 0: String +setSa lary(salary: int void +printInfo0: void Faculty Staff -department: String -rank: String +Faculty(name: String, phoneNumber: -title: String +Staff(name String, phoneNumber: String, email: String, office: String String, email: String, office: String salary: int, title: String) +Staff(title: String) tgetTitle0: String +setTitle(title: String): void tprintInfo0: void salary: int, department: String rank String) +Faculty(department: String, rank String) tgetD epartmentO: String +setDepartment(department: String): voi«d getRank0: String +setRank rank String): void tprintInfo0: void Design a main function, which creates a Faculty object and a Staff object using one of their constructors and invokes their printInfo0 methods

Explanation / Answer

#include <iostream>
using namespace std;

class Employee
{
private:
string name,office,phoneNumber,email;
int salary;

public:
Employee(string name,string phoneNumber,string email,string office,int salary)
{
this->name = name;
this->phoneNumber = phoneNumber;
this->email = email;
this->office = office;
this->salary = salary;
}
Employee(string office,int salary)
{
this->office = office;
this->salary = salary;
}
Employee()
{
name = "";
phoneNumber = "";
email = "";
office = "";
salary = 0;
}
string getName()
{
return name;
}
string getPhoneNumber()
{
return phoneNumber;
}
string getEmail()
{
return email;
}
string getOffice()
{
return office;
}
void setOffice(string office)
{
this->office = office;
}
int getSalary()
{
return salary;
}
void setSalary(int salary)
{
this->salary = salary;
}
void printInfo()
{
cout<<" Employee Name : "<<name<<" Phone Number : "<<phoneNumber<<" Email : "<<email<<" Office : "<<office <<" Salary : "<<salary;

}
};
class Faculty : public Employee
{
private:
string department,rank;

public:
Faculty(string name,string phoneNumber,string email,string office,int salary,string department,string rank):Employee(name,phoneNumber,email,office,salary)
{

this->department = department;
this->rank = rank;
}
Faculty(string department,string rank)
{
this->department = department;
this->rank = rank;
}
string getDepartment()
{
return department;
}
void setDepartment(string department)
{
this->department = department;
}
string getRank()
{
return rank;
}
void setRank(string rank)
{
this->rank = rank;
}
void printInfo()
{

cout<<" Employee Name : "<<getName()<<" Phone Number : "<<getPhoneNumber()<<" Email : "<<getEmail()<<" Office : "<<getOffice() <<" Salary : "<<getSalary()<<"Department : "<<department <<" Rank : "<<rank;
}
};
class Staff : public Employee
{
private:
string title;

public:
Staff(string name,string phoneNumber,string email,string office,int salary,string title):Employee(name,phoneNumber,email,office,salary)
{

this->title = title;
}
Staff(string title)
{
  this->title = title;
}
string getTitle()
{
  return title;
}
void setTitle(string title)
{
  this->title = title;
}
void printInfo()
{
  cout<<" Title : "<<title;
}

};
int main() {

Employee *e,*e1; //base class pointer

e = new Faculty("Adam Jones","679-755858","adam@mail.com","350 Fifth Avenue, 34th floor New York, NY",85000,"Account","senior");

e->printInfo();

e1 = new Staff("Paula Williams","877-767687","paulaw@mail.com","55 East 59 Street, Suite 19B, New York NY",76000,"Mrs");

e1->printInfo();

return 0;
}

Output:

Employee Name : Adam Jones Phone Number : 679-755858 Email : adam@mail.com Office : 350 Fifth Avenue, 34th floor New York, NY Salary : 85000
Employee Name : Paula Williams Phone Number : 877-767687 Email : paulaw@mail.com Office : 55 East 59 Street, Suite 19B, New York NY Salary : 76000


Do ask if any doubt. Please upvote