Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with this lab, must be done in c++. Create a C++ project, and call it Week 5Inheritance. Now, let's realize the UML class

Need help with this lab, must be done in c++.

Create a C++ project, and call it Week 5Inheritance. Now, let's realize the UML class diagram, which means let's take the UML class diagram to code.

Create an Employee class using a separate header file and implementation file. Review your UML class diagram for the attributes and behaviors

The calculatePay() method should return 0.0f.

The toString() method should return the attribute values ("state of the object").

Create an Hourly class using a separate header file and implementation file.

The Hourly class needs to inherit from the Employee class

The calculatePay() method should return the pay based on the number of hours worked and the pay rate. Remember to calculate overtime!

Create a Salary class using a separate header file and implementation file.

The Salary class needs to inherit from the Employee class.

The calculatePay() method should return the annualSalary divided by 52.0f because there are 52 weeks in the year.

Create a Manager class using a separate header and implementation file.

The Manager class needs to inherit from the Salary class (yes, a Child class can be a Parent class).

The calculatePay() method should use the Salary's calculatePay() method plus the bonus divided by 52.0f (base pay plus bonus).

Here is what I have so far. Hourly.cpp

#include "Hourly.h"

#include "Employee.h"

#include

#include

#include

using namespace std;

Hourly::Hourly(double hoursWorked, double hourlyRate)

{

hours = hoursWorked;

payRate = hourlyRate;

}

Hourly::~Hourly()

{

}

float Hourly::calculatePay()

{

//payRate and hours can be used

float totalPay;

float overTimePay;

if (hours > 40)

{

overTimePay = 40 * payRate * (hours - 40);

totalPay = overTimePay + 40 * payRate;

}

else

{

totalPay = payRate * hours;

}

return totalPay;

}

string Hourly::toString()

{

return "state of the object";

}

Hourly.h

#pragma once

#include

#include "Employee.h"

using namespace std;

class Hourly : Employee

{

double payRate;

double hours;

public:

Hourly();

~Hourly();

string toString() override;

float calculatePay() override;

};

Employee.cpp:

#include "Employee.h"

#include

#include

#include

using namespace std;

Employee::Employee()

{

}

Employee::~Employee()

{

}

float Employee::calculatePay()

{

return 0.0;

}

string Employee::toString()

{

return "state of the object";

}

Employee.h

#pragma once

#include

#include

#include

using namespace std;

class Employee

{

public:

Employee();

~Employee();

virtual float calculatePay();

virtual std::string toString();

};

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Technology And Management Computers And Information Processing Systems For Business

Authors: Robert C. Goldstein

1st Edition

0471887374, 978-0471887379

More Books

Students also viewed these Databases questions

Question

Understand the role of corporate design in communications.

Answered: 1 week ago