-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHourlyEmployee.cpp
More file actions
42 lines (36 loc) · 1.17 KB
/
HourlyEmployee.cpp
File metadata and controls
42 lines (36 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) 2024. Howard Community College All Rights Reserved. Unauthorized Duplication Prohibited.
//
#include <iomanip>
#include "HourlyEmployee.h"
using namespace std;
/*
* Constructs the HourlyEmployee with the double hoursWorked and the double payRate
* Correspondingly constructs the base class with ID and name
*/
HourlyEmployee::HourlyEmployee(int ID, std::string name, double hoursWorked, double payRate) : Employee(ID, name) {
HourlyEmployee::hoursWorked = hoursWorked;
HourlyEmployee::payRate = payRate;
}
/*
* Overridden function for printPay that prints the string Name, int ID, double Weekly Pay
* as given by hoursWorked * payRate
*/
void HourlyEmployee::printPay() {
cout << "Name: " << this->getName() << endl
<< "ID: " << this->getID() << endl;
cout << setprecision(2);
cout << fixed;
cout << "Weekly Pay: $" << hoursWorked * payRate << endl << endl;
}
/*
* Returns the number of hours worked by the employee
*/
double HourlyEmployee::getHoursWorked() const {
return HourlyEmployee::hoursWorked;
}
/*
* Returns the pay rate of the employee
*/
double HourlyEmployee::getPayRate() const {
return HourlyEmployee::payRate;
}