Before you start, download all files. Analyse given code.

Part 1

Create a class template (in file Pair.h) which represents a pair of variables of any type.

template < class T1, class T2>
class Pair

This class template should posses two private member fields (a and b) of type T1 and T2. Provide also appropriate constructor (according to class template usage in main) and const methods first and second which return a value of first and second element from pair. Define also a friend function operator<< which prints on the screen values of first and second element from the pair.

All class template methods should be implemented outside class body.

Part 2

A declaration and implementation of an abstract base class presonType is given (in files Employee.h and Employee.cpp). Inherit (using public inheritance) two classes: partTimeEmployee and fullTimeEmployee, so that all classes create a polymorphic class hierarchy.

Class partTimeEmployee posses private member fields fullTimeWages and employmentPart (of type Pair< double, string> and double accordingly). Class fullTimeEmployee posses private member field fullTimeWages (of type Pair< double, string>).

In both classes field Pair< double, string> fullTimeWages represents employee wages so that first element in pair is employee amount of wages and second element in pair is a symbol of currency (e.g. Pair< double, string> fullTimeWages(2000, PLN) represents wages of 2000 paid in PLN).

Method calculatePay calculates and returns employee wages. In case of partTimeEmployee wages is equal to fullTimeWages (you need to select the appropriate member of the pair) multimplied by employmentPart.

For both classes provide appropriate class interface. Use inheritance idea DO NOT reimplement things unnecessarily (this wont by pointed). See example class usage and example output in main.

Part 3

Implement a class Team, which represents a group of employee (hold in STL list container). Declaration of class Team is given in header file Team.h.

Method add adds a new employee to list (use method push_back).

Method display displays content of employee list (prints all employees to the screen).

Class destructor deletes each list element content.

Part 4

In class Team uncomment method toRetire. This method deletes from employee list (using remove_if method) all persons with age bigger than retirement age (holds in binary predicate member field). In file Team.h define binary predicate (implemented as a class isRetired) necessary for proper operation of the method toRetired (used as an argument for remove_if).

See example class usage and example output in main.

Part 5

In binary predicate class isRetired (in method operator()) add an exception handling mechanism, so that if given retirement age is smaller than 18 (assuming that minors are not working) a standard library exception invalid_argument is thrown. All exception mechanism (try/catch/throw) should be implemented inside operator() implementation.

Example

Example output: See image.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.