-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
80 lines (63 loc) · 2.11 KB
/
Copy pathmain.cpp
File metadata and controls
80 lines (63 loc) · 2.11 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
#include <iostream>
#include "Employee.h"
#include "Supervisor.h"
#include "Officer.h"
using namespace std;
/**
* @brief Runs a standard set of tests on an Employee object.
*
* @param e Employee (or derived class) reference to test
*/
void runEmployeeTests(Employee & e);
int main() {
// Test default Employee constructor
Employee defaultE;
cout << "Testing Employee default constructor:" << endl;
runEmployeeTests(defaultE);
cout << endl << endl;
// Test parameterized Employee constructor
// ID: 1248, years: 2, hourlyRate: 15.23, hoursWorked: 3
Employee parameterizedE(1248, 2, 15.23, 3);
cout << "Testing Employee parameterized constructor:" << endl;
runEmployeeTests(parameterizedE);
cout << endl << endl;
// Test default Supervisor constructor
Supervisor defaultS;
cout << "Testing Supervisor default constructor:" << endl;
runEmployeeTests(defaultS);
cout << endl << endl;
// Test parameterized Supervisor constructor
// ID: 422, years: 9, hourlyRate: 55.44, hoursWorked: 20, numSupervised 52
cout << "Testing Supervisor parameterized constructor:" << endl;
Supervisor parameterizedS(422, 9, 55.44, 20, 52);
runEmployeeTests(parameterizedS);
cout << endl << endl;
// Test default Officer constructor
Officer defaultO;
cout << "Testing Officer default constructor:" << endl;
runEmployeeTests(defaultO);
cout << endl << endl;
// Test parameterized Officer constructor
// ID: 2, years = 94, hourlyRate: 10.859, hoursWorked: 2, evilness 9000.1
Officer parameterizedO(2, 94, 10.859, 2, 9000.1);
cout << "Testing Officer parameterized constructor:" << endl;
runEmployeeTests(parameterizedO);
return 0;
}
/**
* @brief Runs a full test cycle on an Employee object.
*
* Calls print, calculatePay, anniversary, and print again
* to verify behavior of derived and base classes.
*
* @param e Employee reference to test
*/
void runEmployeeTests(Employee &e) {
cout << "Initial print():" << endl;
e.print();
cout << "Calculated Pay: " << e.calculatePay() << endl;
cout << "Anniversary Test: ";
e.anniversary();
cout << "Final print():" << endl;
e.print();
}