-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSalariedEmp.cpp
More file actions
64 lines (49 loc) · 2.25 KB
/
SalariedEmp.cpp
File metadata and controls
64 lines (49 loc) · 2.25 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "SalariedEmp.h" // class implemented
using namespace std;
// File scope starts here
/////////////////////////////// PUBLIC ///////////////////////////////////////
//============================= LIFECYCLE ====================================
// SalariedEmp Default + Overloaded Constructor
SalariedEmp::SalariedEmp(const string& aName, const string& aNIC, const Date& aDateOfBirth, const Date& aDateOfHire, const Address& aHomeAddress, double aTaxRate, double aBasicSalary) : Employee(aName, aNIC, aDateOfBirth, aDateOfHire, aHomeAddress, aTaxRate, aBasicSalary) {
// base class initilzation using member initlizer list
}
// end SalariedEmp constructor
//============================= OPERATIONS ===================================
// Overriding function that prints all the details of the Salaried employee.
void SalariedEmp::PrintEmployee()const {
Employee::PrintEmployee();
cout << "Net Salary: " << this->CalcSalary() << endl;
}
// end function PrintEmployee
// Overriding function that calculates net salary.
double SalariedEmp::CalcSalary() const{
double basicSalary, taxRate, grossSalary, tax, netSalary;
basicSalary = this->GetBasicSalary();
taxRate = this->GetTaxRate();
grossSalary = basicSalary + 0.0;
tax = grossSalary * taxRate;
netSalary = grossSalary - tax;
return netSalary;
}
// end function CalcSalary
//============================= ACESS ===================================
// function that sets SalariedEmp
void SalariedEmp::SetSalariedEmp(const string& aName, const string& aNIC, const Address& aHomeAddress, double aTaxRate, double aBasicSalary) {
this->SetEmployee(aName, aNIC, aHomeAddress, aTaxRate, aBasicSalary);
}
// end function SetSalariedEmp
// overloaded function that sets SalariedEmp
void SalariedEmp::SetSalariedEmp(const Employee& aEmployee) {
this->SetEmployee(aEmployee.GetEmployee());
}
// end function SetSalariedEmp
// overloaded function that sets SalariedEmp
void SalariedEmp::SetSalariedEmp(const SalariedEmp& aSalariedEmp) {
this->SetSalariedEmp(aSalariedEmp.GetEmployee());
}
// end function SetSalariedEmp
// function that gets the SalariedEmp
const SalariedEmp& SalariedEmp::GetSalariedEmp()const {
return *this;
}
// end function GetSalariedEmp