47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
#include "Employee.h"
|
|
#include "SalaryEmployee.h"
|
|
|
|
|
|
SalaryEmployee::SalaryEmployee() {
|
|
this->salary = 0;
|
|
this->bonus = 0;
|
|
}
|
|
SalaryEmployee::SalaryEmployee(SalaryEmployee &) : Employee() {
|
|
this->salary = 0;
|
|
this->bonus = 0;
|
|
}
|
|
SalaryEmployee::SalaryEmployee(const char * pName, int salary, int bonus) {
|
|
setName(pName);
|
|
this->salary = salary;
|
|
this->bonus = bonus;
|
|
}
|
|
|
|
SalaryEmployee::~SalaryEmployee() = default;
|
|
|
|
|
|
double SalaryEmployee::computePay() {
|
|
return salary + bonus;
|
|
}
|
|
|
|
double SalaryEmployee::weeklyPay() {
|
|
return computePay() * 7;
|
|
}
|
|
|
|
SalaryEmployee & SalaryEmployee::operator=(SalaryEmployee & other) {
|
|
// Check for self-assignment
|
|
if (this == &other) {
|
|
return *this; // Return reference to the current object
|
|
}
|
|
// Perform member-wise assignment
|
|
salary = other.salary;
|
|
bonus = other.bonus;
|
|
return *this; // Return reference to the current object
|
|
}
|
|
|
|
std::string SalaryEmployee::toString() {
|
|
std::string returnString;
|
|
returnString.append("Employee Name: ").append(getName()).append("\n")
|
|
.append("Salary: ").append(std::to_string(salary)).append("\n")
|
|
.append("Bonus: ").append(std::to_string(bonus)).append("\n");
|
|
return returnString;
|
|
} |