Answer to Question #205182 in C++ for Ahmad

Question #205182

Following is the a simple diagram for a class hierarchy of an employee, you are required to map the

diagram to C++ Code , Each class should have a default and an overloaded constructor and a function

named as SalaryCalculator() which calculates the pay according to the employee the employer have.

Parent class :Employee

Employee child classes:

1)SalariedEmployee

2)CommissionEmployee

3)HourlyEmployee

Employee and CommissionEmployee child class:

1)Base plus Commission Employee

Implement:

 Inheritance

 Dynamic Polymorphism

 A main( ) which can test all the classes


1
Expert's answer
2021-06-11T00:10:00-0400
#include <iostream>

using namespace std;

class Employee {
private:
    string name;
public:
    Employee()
    {
        this->name = "unknown";
    }
    Employee(string name) 
    {
        this->name = name;
    }
    virtual double SalaryCalculator();
};

class SalariedEmployee : Employee {
public:
    SalariedEmployee() : Employee() 
    {}
    SalariedEmployee(string name) : Employee(name) 
    {}
    double SalaryCalculator() 
    {
        // method impl...
        return 0.0;
    }
};

class CommistionEmployee : Employee {
public:
    CommistionEmployee() : Employee() 
    {}
    CommistionEmployee(string name) : Employee(name) 
    {}
    double SalaryCalculator() 
    {
        // method impl...
        return 0.0;
    }
};

class HourlyEmployee : Employee {
public:
    HourlyEmployee() : Employee() 
    {}
    HourlyEmployee(string name) : Employee(name) 
    {}
    double SalaryCalculator() 
    {
        // method impl...
        return 0.0;
    }
};

int main()
{

   return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog