This repository was archived by the owner on Jan 27, 2023. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathemployee.cpp
More file actions
121 lines (104 loc) · 5.85 KB
/
Copy pathemployee.cpp
File metadata and controls
121 lines (104 loc) · 5.85 KB
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
/*----------------------------------------------------------------------------+
| Author: Jerome Richards |
| |
| Assignment: Project 1 |
| File: employee.cpp |
| |
| Instructor: Dr. Roger deBry |
| Class: CNS-1350 Section X01 |
| |
| Date Written: January 8, 2005 |
| |
| Description: Employee class implementation |
+----------------------------------------------------------------------------*/
#include <cassert>
#include <iostream>
#include "employee.h"
/*----------------------------------------------------------------------------+
| Purpose: Initialize the Employee class object |
| Parameters: |
| Returns: nothing |
| |
| Pre-conditions: theEmpNum > 0 |
| theDeptNum > 0 |
| theName length is > 0 |
| theWeeklySalary > 0 |
| theCommRate > 0 |
| |
| Post-conditions: itsWeeklySales == 0.0 |
+----------------------------------------------------------------------------*/
CEmployee::CEmployee( int theEmpNum,
string theAddr,
string thePhone,
int theDeptNum,
string theName,
double theWeeklySalary,
double theCommRate
)
{
assert( theEmpNum > 0 );
assert( theDeptNum > 0 );
assert( theName.size() > 0 );
assert( theWeeklySalary > 0 );
assert( theCommRate > 0 );
itsEmpNumber = theEmpNum;
itsAddress = theAddr;
itsPhoneNumber = thePhone;
itsDeptNumber = theDeptNum;
itsName = theName;
itsWeeklySalary = theWeeklySalary;
itsCommissionRate = theCommRate;
itsWeeklySales = 0.0;
assert( itsWeeklySales == 0.0 );
}
/*----------------------------------------------------------------------------+
| Purpose: Return the employee name stored in the current object |
| Parameters: none |
| Returns: a string object containing the employee name |
| |
| Pre-conditions: none |
| Post-conditions: none |
+----------------------------------------------------------------------------*/
string CEmployee::getName()
{
return itsName;
}
/*----------------------------------------------------------------------------+
| Purpose: Set the weekly sales amount for the current object |
| |
| Parameters: theWeeklySales a double containing the total amount of |
| sales for the week |
| |
| Returns: nothing |
| |
| Pre-conditions: theWeeklySales must be greater than or equal to zero |
| Post-conditions: none |
+----------------------------------------------------------------------------*/
void CEmployee::setWeeklySales( double theWeeklySales )
{
assert( theWeeklySales >= 0.0 );
itsWeeklySales = theWeeklySales;
}
/*----------------------------------------------------------------------------+
| Purpose: Calculate the minimum weekly pay for the current employee |
| object. |
| |
| The greater of the itsWeeklySalary |
| and itsWeeklySales * itsCommissionRate is used. |
| |
| Parameters: none |
| |
| Returns: thePay a double representing the minimum weekly salary |
| |
| Pre-conditions: none |
| Post-conditions: thePay must be greater than or equal to zero |
+----------------------------------------------------------------------------*/
double CEmployee::calcPay()
{
double thePay = 0.0;
thePay = itsWeeklySales * itsCommissionRate;
if( thePay < itsWeeklySalary )
thePay = itsWeeklySalary;
assert( thePay >= 0.0 );
return thePay;
}