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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
|
#include <iostream>
#include <string>
#include <cstring>
#include <iomanip>
using namespace std;
/***********************************
* Function Prototypes *
***********************************/
void DisplayApplicationInformation();
void DisplayDivider(string);
string GetInput(string);
void TerminateApplication();
/***********************************
* Global Variables *
***********************************/
string input;
/***********************************
* Benefit Class Definition *
***********************************/
class Benefit: public Employee{
private:
string healthInsurance;
double lifeInsurance;
int vacation;
public:
void benefit();
void benefit(string health, double life, int vacation);
void displayBenefits();
string getHealthInsurance();
void setHealthInsurance(string hIns);
double getLifeInsurance();
void setLifeInsurance(double lifeIns);
int getVacation();
void setVacation(int vaca);
};
/***********************************
* iEmployee Interface Class *
***********************************/
class iEmployee:public Employee{
public:
virtual double calculateWeeklyPay(double) = 0;
};
/***********************************
* Employee Class Definition *
***********************************/
class Employee{
protected:
string firstName;
string lastName;
char gender;
int dependents;
double annualSalary;
Benefit benefit;
private:
static int numEmployees;
public:
void employee();
void employee(string first, string last, char gen, int dep, double salary);
double calculateWeeklyPay(double);
void displayEmployee();
string getFirstName();
void setFirstName(string first);
string getLastName();
void setLastName(string last);
char getGender();
void setGender(char gen);
int getDependents();
void setDependents(int dep);
double getAnnualSalary();
void setAnnualSalary(double salary);
static int getNumEmployees();
void setDependents(string dependents);
void setAnnualSalary(string salary);
};
/***********************************
* Salaried Class Definition *
***********************************/
class Salaried : public Employee{
private:
const int MIN_MANAGEMENT_LEVEL;
const int MAX_MANAGEMENT_LEVEL;
const double BONUS_PERCENT;
int managementLevel;
public:
void salaried();
void salaried(string first, string last, char gen, int dep, double salary, Benefit ben, int manLevel);
void salaried(double salary, int manLevel);
double Calculate();
void displayEmployee();
int getManagementLevel();
void setManagementLevel(int manLevel);
void setAnnualSalary(string salary);
};
/***********************************
* Hourly Class Definition *
***********************************/
class Hourly:public Employee{
private:
const double MIN_WAGE;
const double MAX_WAGE;
const double MIN_HOURS;
const double MAX_HOURS;
double wage;
double hours;
string category;
public:
void hourly();
void hourly(double wage, double hours, string category);
void hourly(string first, string last, char gen, int dep, double salary, Benefit ben, int manLevel);
double calculatePay();
void setAnnualSalary();
void displayEmployee();
double getWage();
void setWage(double wage);
double getHours();
void setHours(double hours);
string getCategory();
void setCategory(string category);
};
/***********************************
* Employee Class Methods *
***********************************/
void Employee::employee(){
firstName = "Not given";
lastName = "Not given";
gender = 'U';
dependents = 0;
annualSalary = 20,000;
numEmployees++;
}
void Employee::employee(string first, string last, char gen, int dep, double salary){
first = firstName;
last = lastName;
gen = gender;
dep = dependents;
salary = annualSalary;
numEmployees++;
}
double Employee::calculateWeeklyPay(double){
return annualSalary/52;
}
void Employee::displayEmployee(){
numEmployees++;
cout << "Name: " << lastName << ", " << firstName << endl;
cout << "Gender: " << gender << endl;
cout << "Dependents: " << dependents << endl;
cout << "Annual Salary:\t" << setprecision(2) << showpoint << fixed << annualSalary << "\n";
cout << "Weekly Pay:\t" << setprecision(2) << showpoint << fixed << annualSalary/52 << "\n";
}
string Employee::getFirstName(){
return firstName;
}
void Employee::setFirstName(string first){
firstName = GetInput("Employee's First Name");
}
string Employee::getLastName(){
return lastName;
}
void Employee::setLastName(string last){
lastName = GetInput("Employee's Last Name");
}
char Employee::getGender(){
return gender;
}
void Employee::setGender(char gen){
input = GetInput("Employee's Gender");
gender = input[0];
}
int Employee::getDependents(){
return dependents;
}
void Employee::setDependents(int dep){
input = GetInput("Number of Employee's Dependents");
dependents = atoi(input.c_str());
}
double Employee::getAnnualSalary(){
return annualSalary;
}
void Employee::setAnnualSalary(double salary){
input = GetInput("Employee's Salary");
annualSalary = atof(input.c_str());
}
int Employee::numEmployees = 0;
int Employee::getNumEmployees(){
return numEmployees;
}
void Employee::setDependents(string dep){
input = GetInput("Number of Employee's Dependents");
dependents = atoi(input.c_str());
}
void Employee::setAnnualSalary(string salary){
input = GetInput("Employee's Salary");
annualSalary = atoi(input.c_str());
}
/***********************************
* Benefit Class Methods *
***********************************/
void Benefit::benefit(){
healthInsurance = "Not given";
lifeInsurance = 0;
vacation = 0;
}
void Benefit::benefit(string health, double life, int vaca){
health = healthInsurance;
life = lifeInsurance;
vaca = vacation;
}
void Benefit::displayBenefits(){
cout << "Health Insurance: " << healthInsurance << endl;
cout << "Life Insurance: " << lifeInsurance << endl;
cout << "Vacation: " << vacation << endl;
}
string Benefit::getHealthInsurance(){
return healthInsurance;
}
void Benefit::setHealthInsurance(string hIns){
input = GetInput("Health Insurance");
healthInsurance = input;
}
double Benefit::getLifeInsurance(){
return lifeInsurance;
}
void Benefit::setLifeInsurance(double lifeIns){
input = GetInput("Life Insurance");
lifeInsurance = atoi(input.c_str());
}
int Benefit::getVacation(){
return vacation;
}
void Benefit::setVacation(int vaca){
input = GetInput("Vacation Time");
vacation = atoi(input.c_str());
}
|