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

Please read the question carefully.....it involves use of templates....its a har

ID: 666701 • Letter: P

Question

Please read the question carefully.....it involves use of templates....its a hard assignment

i gave an example of the class template that we need to use.its best in oop;headers and implementation

Create a class template, called CompanyTemplate, which can be used to generate classes such as the one defined as above. Provide the definition and implementation of the class CompanyTemplate. Have a driver to test your template class. example:

template<typename T>

class CompanyTemplate{

public:

void addEmployee(T& e);

void removeEmployee(T& e);

// other member functions;

private:

T* elist;

int numberOfEmployee;

int size;

//other data members;

};

We want to create a C++ system that manages the employees of a pharmaceutical company. The company has two types of employees: Researchers and Administrators. Both types of employees have the following properties: employee id (int), name (string), position (string), seniority (int). In addition, researchers have the following attributes: title (string) and area of expertise (string). Administrative employees have the following additional attributes: number of employees that are managed by the employee (int). It is up to you to decide how many classes are needed. You decide about which functions should be virtual, constant, etc. You need to provide both a class definition and implementation. Each class must have at least the following functions: • A default constructor, a regular constructor, a copy constructor, a destructor • Accessing functions • A print function

The class Company has the following attributes: name (string) address (string), list of employees (an array of objects of the Employee class), and number of employees the company has (int). The class must implement the following functions: • A default constructor, a regular constructor, a copy constructor, a destructor • Accessing functions • A function that adds an employee to the company (an exception should be thrown if the employee already exists) • A function that removes an employee from the company (an exception should be thrown if the employee does not exist) • A function that returns the number of employees of the company • A function that returns the list (names) of the employees • A function that prints out the name and address of the company

Explanation / Answer

Administrator.cpp

#include <iostream>

#include "Administrator.h"

Administrator::Administrator()
{

}

Administrator::Administrator(string name, string position, int seniority, int numManagedEmp) :Employee(name,position,seniority), numManagedEmp(numManagedEmp)
{
}

Administrator::Administrator(const Administrator& administrator) :Employee(administrator), numManagedEmp(administrator.getNumManagedEmp())
{

}

// modifies number of managed employees
void Administrator::setNumManagedEmp(int numManagedEmp)
{
    this->numManagedEmp = numManagedEmp;
}

// returns the number of managed employees
int Administrator::getNumManagedEmp() const
{
    return numManagedEmp;
}

// prints administator's informations - overrides print of Employee
void Administrator::print() const
{
Employee::print();
cout << " - number of managed employees: " << getNumManagedEmp();
}

Administrator::~Administrator()
{

}

Administrator.h

#ifndef ADMINISTRATOR_H_
#define ADMINISTRATOR_H_

#include "Employee.h"

class Administrator : public Employee
{
public:
Administrator(); // default constructor
Administrator(string name, string position, int seniority, int numManagedEmp); // regular constructor
Administrator(const Administrator& administrator); // copy constructor

void setNumManagedEmp(int); // modifies number of managed employees
    int getNumManagedEmp() const; // returns number of managed employees

    virtual void print() const; // prints administator's informations

virtual ~Administrator();

private:
int numManagedEmp; // number of managed employees
};

#endif /* ADMINISTRATOR_H_ */

Company.cpp

#include "Company.h"

Company::Company()
{

}

Company::Company(string name, string address) :name(name), address(address), numberOfEmployees(0), employees(new Employee[Company::MAX_EMPLOYEES_SIZE])
{

}

Company::Company(const Company& company) :
name(company.getName()), address(company.getAddress()), numberOfEmployees(company.getNumberOfEmployees()),
employees(new Employee[Company::MAX_EMPLOYEES_SIZE])
{
for (int ii = 0; ii < getNumberOfEmployees(); ii++)
{
  this->employees[ii] = company.employees[ii];
}
}

void Company::setName(string name)
{
this->name = name;
}

string Company::getName() const
{
return name;
}

void Company::setAddress(string address)
{
this->address = address;
}

string Company::getAddress() const
{
return address;
}

int Company::getNumberOfEmployees() const
{
return numberOfEmployees;
}

Employee Company::getEmployeeAtPosition(int position) const
{
return employees[position];
}

Company::~Company()
{
employees = NULL;
}


Company.h

#ifndef COMPANY_H_
#define COMPANY_H_

#include <string>

#include "Employee.h"

using namespace std;

class Company
{
public:
Company();
Company(string name, string address);
Company(const Company& company);

void setName(string name);
string getName() const;
void setAddress(string address);
string getAddress() const;
int getNumberOfEmployees() const;
Employee getEmployeeAtPosition(int position) const;

virtual ~Company();

private:
static const int MAX_EMPLOYEES_SIZE = 10;

string name;
string address;
int numberOfEmployees;
Employee* employees;
};

#endif /* COMPANY_H_ */

Driver.cpp

#include <iostream>

#include "Employee.h"
#include "Researcher.h"
#include "Administrator.h"
#include "Company.h"

using namespace std;

int main()
{
// Creating employees
Employee employee1("A. B.", "Junior", 2);

employee1.print();

employee1.setPosition("Manager"); // modifies the position of the employee
employee1.setSeniority(5); // modifies the seniority of the employee

employee1.print();

// Creating researchers
Researcher researcher1("E. F.", "Researcher", 5, "Doctor", "Reptiles");

researcher1.print();

// Creating administrators
Administrator administrator1("G. H.", "Administrator", 8, 10);
administrator1.print();

// Creating company
Company company("Company & co.", "Montreal");

}

Employee.cpp

#include <iostream>

#include "Employee.h"

int Employee::idCounter = 0;

Employee::Employee()
{

}

Employee::Employee(string name, string position, int seniority) :id(++idCounter), name(name), position(position), seniority(seniority)
{

}

Employee::Employee(const Employee& employee) :id(employee.getId()), name(employee.getName()), position(employee.getPosition()), seniority(employee.getSeniority())
{

}

void Employee::setId(int id)
{
this->id = id;
}

int Employee::getId() const
{
return id;
}

void Employee::setName(string name)
{
this->name = name;
}

string Employee::getName() const
{
return name;
}

void Employee::setPosition(string position)
{
this->position = position;
}

string Employee::getPosition() const
{
return position;
}

void Employee::setSeniority(int seniority)
{
this->seniority = seniority;
}

int Employee::getSeniority() const
{
return seniority;
}

void Employee::print() const
{
cout << endl << "Employee"
   << " - id: " << getId()
   << " - name: " << getName()
   << " - position: " << getPosition()
   << " - seniority: " << getSeniority();
}

Employee::~Employee() {

}

Employee.h

#ifndef EMPLOYEE_H_
#define EMPLOYEE_H_

#include <string>

using namespace std;

class Employee
{
public:
Employee(); // default constructor
Employee(string name, string position, int seniority); // regular constructor
Employee(const Employee& employee); // copy constructor

void setId(int id); // modifies the id
int getId() const; // returns the id
void setName(string name); // modifies the name
string getName() const; // returns the name
void setPosition(string position); // modifies the position of the employee
string getPosition() const; // returns the position of the employee
void setSeniority(int seniority); // modifies the Seniority of the employee
int getSeniority() const; // returns the Seniority of the employee

virtual void print() const; // prints employee's information

virtual ~Employee(); // destructor

private:
static int idCounter; // employee id counter
int id; // employee id
string name; // name of the employee
string position; // position of the employee
int seniority; // seniority of the employee
};

#endif /* EMPLOYEE_H_ */

Researcher.cpp

#include <iostream>

#include "Researcher.h"

Researcher::Researcher()
{

}

Researcher::Researcher(string name, string position, int seniority, string title, string expertise_area) :Employee(name, position, seniority), title(title), expertise_area(expertise_area)
{

}

Researcher::Researcher(const Researcher& researcher) :
Employee(researcher), title(researcher.getTitle()), expertise_area(researcher.getExpertiseArea())
{

}

void Researcher::setTitle(string title)
{
this->title = title;
}

string Researcher::getTitle() const
{
return title;
}

void Researcher::setExpertiseArea(string expertise_area)
{
this->expertise_area = expertise_area;
}

string Researcher::getExpertiseArea() const
{
return expertise_area;
}

void Researcher::print() const
{
Employee::print();
cout << " - title: " << getTitle()
   << " - area of expertise: " << getExpertiseArea();
}

Researcher::~Researcher()
{

}


Researcher.h

#ifndef RESEARCHER_H_
#define RESEARCHER_H_

#include "Employee.h"

class Researcher : public Employee
{
public:
Researcher(); // default constructor
Researcher(string name, string position, int seniority, string title, string expertise_area); // regular constructor
Researcher(const Researcher& researcher); // copy constructor

void setTitle(string title);
string getTitle() const;
void setExpertiseArea(string expertise_area);
string getExpertiseArea() const;

virtual void print() const; // prints researcher's information

virtual ~Researcher(); // destructor

private:
string title; // researcher's title
string expertise_area; // researcher's area of expertise
};

#endif /* RESEARCHER_H_ */

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote