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 115
|
// Preprocessor Directives
#include "stdafx.h"
#include "Hourly.h"
#include <iostream>
#include <iomanip>
//----------------------------------------------------------------------------------------------
// Declare Variables
const double minWage = 10;
const double maxWage = 75;
const double minHours = 0;
const double maxHours = 50;
// Default Hourly Constructor
Hourly::Hourly() : Employee(), minWage(10), maxWage(75), minHours(0), maxHours(50)
{
wage = 0.0;
hours = 0.0;
category = "X";
}
//----------------------------------------------------------------------------------------------
// Multi-Arg Hourly Constructor #1
Hourly::Hourly(double wages, double hours, string category) : Employee(), minWage(10), maxWage(75), minHours(0), maxHours(50)
{
setWage(wages);
setHours(hours);
setCategory(category);
setAnnualSalary(calculatePay());
}
//----------------------------------------------------------------------------------------------
// Multi-Arg Hourly Constructor #2
Hourly::Hourly(string firstName, string lastName, char gender, int dependents, double wages, double hours, Benefit benefit, string category) :
Employee(firstName, lastName, gender, dependents, 0, benefit), minWage(10), maxWage(75), minHours(0), maxHours(50)
{
setWage(wages);
setHours(hours);
setCategory(category);
setAnnualSalary(calculatePay());
}
//----------------------------------------------------------------------------------------------
// Default Hourly Deconstructor
Hourly::~Hourly()
{
}
//----------------------------------------------------------------------------------------------
// CalculatePay Override Function
double Hourly::calculatePay()
{
return wage * hours;
}
//----------------------------------------------------------------------------------------------
//Overloaded SetAnnualSalary
void Hourly::setAnnualSalary(double salary)
{
Employee::setAnnualSalary(calculatePay()*50);
}
//----------------------------------------------------------------------------------------------
// DisplayEmployee Override Function
void Hourly::displayEmployee(void)
{
Employee::displayEmployee();
cout<<"Hourly Employee\n";
cout<<"Category:\t\t" << category << "\n";
cout<<"Wage:\t\t\t" << getWage() << "\n";
cout<<"Hours:\t\t\t" << hours << "\n";
}
//----------------------------------------------------------------------------------------------
// GetWage and SetWage Functions
double Hourly::getWage()
{
return wage;
}
void Hourly::setWage(double wages)
{
if(wages >= minWage && wages >= maxWage)
wage = wages;
else if (wages < minWage)
wage = minWage;
else if (wages > maxWage)
wage = maxWage;
setAnnualSalary(calculatePay());
}
//----------------------------------------------------------------------------------------------
//GetHours and SetHours Function
double Hourly::getHours()
{
return hours;
}
void Hourly::setHours(double hour)
{
if (hour >= minHours && hour <= maxHours)
hours = hour;
else if(hour < minHours)
hours = minHours;
else if(hour > maxHours)
hours = maxHours;
setAnnualSalary(calculatePay());
}
//----------------------------------------------------------------------------------------------
// GetCategory and SetCategory Functions
string Hourly::getCategory()
{
return category;
}
void Hourly::setCategory(string cat)
{
if(cat == "temporary" || cat == "part time" || cat == "full time")
category = cat;
else
category = "Unknown";
}
//----------------------------------------------------------------------------------------------
|