#pragma once
#include
using std::string;
class Employee
{
public:
Employee(void);
~Employee(void);
void SetName(string);
string GetName();
void SetHireDate(string);
string GetHireDate();
virtual double CalculateWeeklyPay();
private:
string name;
string hireDate;
};
Employee.cpp
#include "Employee.h"
Employee::Employee(void)
{
}
Employee::~Employee(void)
{
}
void Employee::SetName(string employeeName)
{
name=employeeName;
}
string Employee::GetName()
{
return name;
}
void Employee::SetHireDate(string date)
{
hireDate=date;
}
string Employee::GetHireDate()
{
return hireDate;
}
double Employee::CalculateWeeklyPay()
{
return 0;
}
HourlyEmployee.h
#pragma once
#include "employee.h"
class HourlyEmployee :
public Employee
{
public:
HourlyEmployee(void);
~HourlyEmployee(void);
void SetRate(double);
double GetRate();
void SetHours(double);
double GetHours();
double CalculateWeeklyPay();
private:
double rate;
double hours;
};
HourlyEmployee.cpp
#include "HourlyEmployee.h"
HourlyEmployee::HourlyEmployee(void)
{
}
HourlyEmployee::~HourlyEmployee(void)
{
}
void HourlyEmployee::SetRate(double payRate)
{
rate=payRate;
}
double HourlyEmployee::GetRate()
{
return rate;
}
void HourlyEmployee::SetHours(double hrs)
{
hours=hrs;
}
double HourlyEmployee::GetHours()
{
return hours;
}
double HourlyEmployee::CalculateWeeklyPay()
{
return hours * rate;
}
SalaryEmployee.h
#pragma once
#include "employee.h"
class SalaryEmployee :
public Employee
{
public:
SalaryEmployee(void);
~SalaryEmployee(void);
void SetSalary(double);
double GetSalary();
double CalculateWeeklyPay();
private:
double salary;
};
SalaryEmployee.cpp
#include "SalaryEmployee.h"
SalaryEmployee::SalaryEmployee(void)
{
}
SalaryEmployee::~SalaryEmployee(void)
{
}
double SalaryEmployee::GetSalary()
{
return salary;
}
void SalaryEmployee::SetSalary(double sal)
{
salary=sal;
}
double SalaryEmployee::CalculateWeeklyPay()
{
return salary/52;
}
Program.cpp
#include "HourlyEmployee.h"
#include "SalaryEmployee.h"
#include <iostream>
using namespace std;
int main()
{
HourlyEmployee he;
he.SetName("Bill Gates");
he.SetHireDate("1972");
he.SetRate(.01);
he.SetHours(80);
HourlyEmployee he2;
he2.SetName("Balmer");
he2.SetHireDate("1972");
he2.SetRate(.02);
he2.SetHours(80);
cout << he.GetName() << endl;
cout << he.GetHireDate() << endl;
cout<< he.GetRate() << endl;
cout << he.CalculateWeeklyPay();
cout << endl;
cout << he2.GetName() << endl;
cout << he2.GetHireDate() << endl;
cout<< he2.GetRate() << endl;
cout << he2.CalculateWeeklyPay();
cout << endl;
SalaryEmployee se;
se.SetName("George");
se.SetHireDate("1/1/2000");
se.SetSalary(80000.00);
cout << se.GetName() << endl;
cout << se.GetHireDate() << endl;
cout << se.CalculateWeeklyPay();
cout << endl;
cin.get();
cin.get();
}
No comments:
Post a Comment