Question

This is done in C++ Create an Employee class using a separate header file and implementation...

This is done in C++

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).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Header File

Class declarations are stored in a separate file. A file that contains a class declaration is called header file. The name of the class is usually the same as the name of the class, with a .h extension.

Implementation File

The member function definitions for a class are stored in a separate .cpp file, which is called the class implementation file. The file usually has the same name as the class, with the .cpp extension.

Structure for the code will be:

Employee.h

#include <string>

#include <iostream>

using namespace std;

class Employee

{

public:

Employee(); //define constructor

float Employee::calculatePay();

string Employee::toString();

};

Employee.cpp:

#include "Employee.h"

#include <string>

#include <iostream>

using namespace std;

Employee::Employee(){ } // define constructor if needed

float Employee::calculatePay(){

return 0.0;

}

string Employee::toString(){

return "State of the Object";

}

Hourly.h

#include <string>

#include "Employee.h"

using namespace std;

class Hourly : public Employee

{

// define variables to calculate pay

public:

Hourly :: Hourly(); // constructor for initial values

float Hourly::calculatePay() override;

};

Hourly.cpp

#include "Hourly.h"

#include "Employee.h"

#include <iostream>

using namespace std;

Hourly::Hourly() { } // define constructor for initial values

float Hourly::calculatePay()

{

// code for calculating Pay according to attributes

return Pay;

}

Salary.h

#include <iostream>

#include "Employee.h"

using namespace std;

class Salary : public Employee

{

// define variables to calculate annualSalary

public:

Salary :: Salary(); // constructor for initial values

float Salary::calculatePay() override;

};

Salary.cpp

#include "Salary.h"

#include "Employee.h"

#include <iostream>

using namespace std;

Salary::Salary() { } // define constructor for initial values

float Salary::calculatePay()

{

// code for calculating annualSalary according to attributes

return annualSalary;

}

Manager.h

#include <string>

#include "Salary.h"

using namespace std;

class Manager : public Salary

{

// define variables to calculate bonus

public:

Manager :: Manager(); // constructor for initial values

float Manager::calculatePay();

};

Manager.cpp

#include "Salary.h"

#include "Manager.h"

#include <iostream>

using namespace std;

Manager::Manager() { } // define constructor for initial values

float Manager::calculatePay()

{

// code for calculating bonus according to attributes

return bonus;

}

Add a comment
Know the answer?
Add Answer to:
This is done in C++ Create an Employee class using a separate header file and implementation...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a C++ project Create an Employee class using a separate header file and implementation file....

    Create a C++ project Create an Employee class using a separate header file and implementation file. 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...

  • The purpose of this lab is to practice the concept of inheritance. We will create an...

    The purpose of this lab is to practice the concept of inheritance. We will create an Hourly class that is an Employee class. In other words, the Hourly class inherits from the Employee class. In addition, we will create a Salary class that inherits from the Employee class. Finally, we will make a Child class work as a Parent class. We will create a Manager class that inherits from the Salary class. Create a C++ project, and call it Week...

  • Use C++ Create a Student header file (C++) . Declare the following operations in the file....

    Use C++ Create a Student header file (C++) . Declare the following operations in the file. setName() setMarks() setDateOfBirth() calculateGrade() - This method should compute and return grades based on the mark the student entered calculateAge() - This method should compute and return age using the DateOfBirth the user entered displayDetails() - This method should return a string displaying all the details of the user. Now write the implementation class for the header file. Now reuse these C++ Code in...

  • IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE. IN C++ Create a header...

    IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE. IN C++ Create a header and implementation file to define an apartment class. Create a driver program to test the class, and create a make file to compile the driver program. Create two files called apartment.h and appartmentImp.cpp along with creating a driver program named testApartment.cpp containing the main function. Program Requirements: • Class attributes should include integers for number of rooms, monthly rent, and square feet, as well...

  • Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEm...

    Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEmployee, HourlyEmployee which extend the Employee class and implements that abstract method. A Salary Employee has a salary, a Commision Employee has a commission rate and total sales, and Hourly Employee as an hourly rate and hours worked Software Architecture: The Employee class is the abstract super class and must be instantiated by one of...

  • Part (A) Note: This class must be created in a separate cpp file Create a class...

    Part (A) Note: This class must be created in a separate cpp file Create a class Employee with the following attributes and operations: Attributes (Data members): i. An array to store the employee name. The length of this array is 256 bytes. ii. An array to store the company name. The length of this array is 256 bytes. iii. An array to store the department name. The length of this array is 256 bytes. iv. An unsigned integer to store...

  • Need a Javascript program for an Employee class with a Constructor Function. It must contain properties...

    Need a Javascript program for an Employee class with a Constructor Function. It must contain properties of name, annualsalary and bonus of multiple employee of a company. It should contain a Method for calculateBonus. The bonus will be 20% of annualsalary. When the calculateBonus method is called, the bonus should be returned as the bonus's return value. Create a Function Called checkEmployee(). This Function when called will instantiate an employee Object Will Call the Employee's calculateBonus Method and when the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT