This repository was archived by the owner on Jan 27, 2023. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathtestEmployee.cpp
More file actions
114 lines (88 loc) · 4.16 KB
/
Copy pathtestEmployee.cpp
File metadata and controls
114 lines (88 loc) · 4.16 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
/*----------------------------------------------------------------------------+
| Author: Jerome Richards |
| |
| Assignment: Project 1 |
| File: testEmployee.cpp |
| |
| Instructor: Dr. Roger deBry |
| Class: CNS-1350 Section X01 |
| |
| Date Written: January 8, 2005 |
| |
| Description: |
| |
| Test the employee class use of assertions, pointers to classes, and |
| salary computation |
+----------------------------------------------------------------------------*/
#include <iostream>
#include <cassert>
using namespace std;
#include "employee.h"
const int TRUE = 1;
const int FALSE = 0;
void dispPrologue();
void setSales( CEmployee* theEmployee );
int main()
{
CEmployee* tmpEmployee = NULL;
tmpEmployee = new CEmployee( 1, "12 Madison Avenue", "123-4567", 100, "I. M. Great", 1000, 0.4 );
assert( tmpEmployee != NULL );
dispPrologue();
setSales( tmpEmployee );
cout << "\nPay for " << tmpEmployee->getName() << " is " << tmpEmployee->calcPay() << "\n";
cin.ignore( 80, '\n' );
cout << "Press any key to continue. . .";
cin.get();
assert( tmpEmployee != NULL );
delete tmpEmployee;
return 0;
};
/*----------------------------------------------------------------------------+
| Purpose: Allow the user to enter the weekly sales amount for the |
| current employee object |
| |
| Parameters: theEmployee a pointer to an employee object |
| Returns: nothing |
| |
| Pre-conditions: a valid pointer to an employee object |
| Post-conditions: none |
+----------------------------------------------------------------------------*/
void setSales( CEmployee* theEmployee )
{
double tmpSales = 0.0;
bool lOK;
assert( theEmployee != NULL );
cout << "Employee name: " << theEmployee->getName() << '\n';
do
{
lOK = TRUE;
cout << "Enter Sales for this week: ";
cin >> tmpSales;
if( ! std::cin )
{
lOK = FALSE;
cin.clear();
cin.ignore( 80, '\n' );
cout << "\nBad input value. Please enter a number.\n";
}
} while( ! lOK );
theEmployee->setWeeklySales( tmpSales );
}
/*----------------------------------------------------------------------------+
| Purpose: Display file prologue |
| Parameters: none |
| Returns: nothing |
| |
| Pre-conditions: none |
| Post-conditions: none |
+----------------------------------------------------------------------------*/
void dispPrologue()
{
system( "cls" );
cout << " Name: Jerome Richards\n";
cout << " Course: CNS-1350 Section X01\n";
cout << "Instructor: Dr. Roger deBry\n";
cout << " Program: Project One\n";
cout << " File: Employee (testEmployee.exe)\n";
cout << "\n\n";
}