Benefit CPP File
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 65 66 67
|
// Preprocessor Directives
#include "stdafx.h"
#include "Employee.h"
#include "Benefit.h"
#include <iostream>
#include <iomanip>
//----------------------------------------------------------------------------------------------
// Default Benefit Constructor
Benefit::Benefit() : healthInsurance("not provided"), lifeInsurance(0.0), vacation(14)
{
}
//----------------------------------------------------------------------------------------------
// Multi-Arg Benefit Constructor
Benefit::Benefit(string health, double life, int vac) :
healthInsurance(health),
lifeInsurance(life),
vacation(vac)
{
}
//----------------------------------------------------------------------------------------------
// Benefit Deconstructor
Benefit::~Benefit()
{
}
//----------------------------------------------------------------------------------------------
// DisplayBenefits Function
void Benefit::displayBenefits()
{
cout << "\nBenefit Information\n";
cout << "----------------------------------------------------------------\n";
cout << "Health Insurance: \t" << healthInsurance << "\n";
cout << "Life Insurance: \t" << setprecision(2) << showpoint << lifeInsurance << "\n";
cout << "Vacation: \t\t" << vacation << " days\n";
}
//----------------------------------------------------------------------------------------------
// Define GetHealthInsurance and SetHealthInsurance
string Benefit::getHealthInsurance()
{
return healthInsurance;
}
void Benefit::setHealthInsurance(string newHealthInsurance)
{
healthInsurance = newHealthInsurance;
}
//----------------------------------------------------------------------------------------------
// Define GetLifeInsurance and SetLifeInsurance
double Benefit::getLifeInsurance()
{
return lifeInsurance;
}
void Benefit::setLifeInsurance(double newLifeInsurance)
{
lifeInsurance = newLifeInsurance;
}
//----------------------------------------------------------------------------------------------
// Define GetVacation and SetVacation
int Benefit::getVacation()
{
return vacation;
}
void Benefit::setVacation(int newVacation)
{
vacation = newVacation;
}
|
Salaried.h File
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
// Preprocessor Directives
#pragma once
#include "employee.h"
class Salaried :
public Employee
{
public:
Salaried(void);
~Salaried(void);
private:
int minManagementLevel;
int maxManagementLevel;
double bonusPercent;
int managementLevel;
public:
Salaried(string firstName, string lastName, char gender, int dependent, double salary, Benefit benefit, int managementLevel);
Salaried(double salary, int managementLevel);
double calculatePay(void);
void displayEmployee(void);
//Getters and Setters
int Salaried::getManagementLevel();
void Salaried::setManagementLevel(int);
};
|
Salaried CPP File
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
|
#include "stdafx.h"
#include "Salaried.h"
#include <iostream>
Salaried::Salaried()
{
const int minManagementLevel = 0;
const int maxManagementLevel = 3;
const double bonusPercent = 0.10;
managementLevel = 0;
}
Salaried::~Salaried(void)
{
}
Salaried::Salaried(string firstName, string lastName, char gender, int dependent, double salary, Benefit benefit, int managementLevel)
{
}
Salaried::Salaried(double salary, int managementLevel)
{
}
double Salaried::calculatePay(void)
{
return Employee::calculatePay()*(1+(managementLevel*bonusPercent));
}
void Salaried::displayEmployee(void)
{
Employee::displayEmployee();
cout<<"Salaried Employee\n";
cout<<"Management Level:\t\t" << managementLevel << "\n";
}
//----------------------------------------------------------------------------------------------
int Salaried::getManagementLevel()
{
return managementLevel;
}
void Salaried::setManagementLevel(int managementLevel)
{
if (managementLevel >= minManagementLevel && managementLevel <= maxManagementLevel)
{
managementLevel = managementLevel;
}
else
{
cout << "Invalid Input" << "\n";
}
}
//----------------------------------------------------------------------------------------------
|
Hourly.h File
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
|
#pragma once
#include "employee.h"
class Hourly :
public Employee
{
public:
Hourly(void);
~Hourly(void);
private:
double minWage;
double maxWage;
double minHours;
double maxHours;
double wage;
double hours;
string category;
public:
Hourly(double wage, double hours, string category);
Hourly(string firstName, string lastName, char gender, int dependents, double wage, double hours, Benefit benefit, string category);
double calculatePay(void);
void displayEmployee(void);
double Hourly::getWage();
void Hourly::setWage(double);
double Hourly::getHours();
void Hourly::setHours(double);
string Hourly::getCategory();
void Hourly::setCategory(string);
void Hourly::setAnnualSalary(double);
};
|
Hourly CPP File
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
#include "stdafx.h"
#include "Hourly.h"
#include <iostream>
using namespace std;
Hourly::Hourly(void)
{
const double minWage = 10.0;
const double maxWage = 75.0;
const double minHours = 0.0;
const double maxHours = 50.0;
wage = 0.0;
hours = 0.0;
}
Hourly::~Hourly(void)
{
}
Hourly::Hourly(double wage, double hours, string category)
{
}
Hourly::Hourly(string firstName, string lastName, char gender, int dependents, double wage, double hours, Benefit benefit, string category)
{
}
double Hourly::calculatePay(void)
{
return (wage * hours);
}
void Hourly::displayEmployee(void)
{
Hourly::setAnnualSalary(annualSalary);
Employee::displayEmployee();
cout<<"Hourly Employee\n";
cout<<"Category:\t\t" << category << "\n";
cout<<"Wage:\t\t\t" << showpoint << fixed << wage << "\n";
cout<<"Hours:\t\t\t" << showpoint << fixed << hours << "\n";
}
double Hourly::getWage()
{
return wage;
}
void Hourly::setWage(double wage)
{
if(wage >= minWage && wage <+ maxWage)
{
this->wage = wage;
}
else if(wage < minWage)
{
this->wage = minWage;
}
else
{
this->wage = maxWage;
}
}
double Hourly::getHours()
{
return hours;
}
void Hourly::setHours(double hours)
{
if (hours > minHours && hours < maxHours)
{
this->hours = hours;
}
else if (hours <= minHours)
{
this->hours = minHours;
}
else
{
this->hours = maxHours;
}
}
string Hourly::getCategory()
{
return category;
}
void Hourly::setCategory(string category)
{
if (category.compare("temporary")==0)
{
this->category = category;
}
else if (category.compare("part time")==0)
{
this->category = category;
}
else if (category.compare("full time")==0)
{
this->category = category;
}
else
{
this->category = "Unknown";
}
}
void Hourly::setAnnualSalary(double salary)
{
salary = calculatePay() * 50;
this->annualSalary = salary;
}
|
|