-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
129 lines (117 loc) · 4.21 KB
/
main.cpp
File metadata and controls
129 lines (117 loc) · 4.21 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
122
123
124
125
126
127
128
129
#include <iostream>
#include <fstream>
#include <array>
#include <string>
#include <cmath>
#include <stdexcept>
#include "employee.h"
#include "Single_Linked_List.cpp"
using namespace std;
Single_Linked_List<int> listS;
int main() {
for (int i = 1; i <= 10; i++) {
listS.push_back(i);
}
int choice, item, index, position;
//creation of two new employees
Employee* emp;
Employee* emp2;
do {
//Menu display
cout << "\n-----MENU-----" << endl;
cout << "Please only enter integers" << endl;
cout << "1. Push front" << endl;
cout << "2. Push back" << endl;
cout << "3. Pop front" << endl;
cout << "4. Pop back" << endl;
cout << "5. Front" << endl;
cout << "6. Back" << endl;
cout << "7. Empty" << endl;
cout << "8. Insert" << endl;
cout << "9. Remove" << endl;
cout << "10. Find" << endl;
cout << "11. Test out classes relating to employees" << endl;
cout << "12. Exit" << endl;
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
cout << "Enter integer to push front: ";
cin >> item;
listS.push_front(item);
break;
case 2:
cout << "Enter integer to push back: ";
cin >> item;
listS.push_back(item);
break;
case 3:
listS.pop_front();
break;
case 4:
listS.pop_back();
break;
case 5:
cout << "Front integer: " << listS.front() << endl;
break;
case 6:
cout << "Back integer: " << listS.back() << endl;
break;
case 7:
if (listS.empty()) {
cout << "List is empty" << endl;
} else {
cout << "List is not empty" << endl;
}
break;
case 8:
cout << "Enter index to insert at: ";
cin >> index;
cout << "Enter integer to insert: ";
cin >> item;
listS.insert(index, item);
break;
case 9:
cout << "Enter index to remove: ";
cin >> index;
if (listS.remove(index)) {
cout << "Integer removed successfully" << endl;
} else {
cout << "Index is beyond the end of the list" << endl;
}
break;
case 10:
cout << "Enter Integer to find: ";
cin >> item;
position = listS.find(item);
if (position == listS.size()) {
cout << "Integer not found" << endl;
} else {
cout << "Integer found at position " << position << endl;
}
break;
case 11:
//Automatic creation and assigning of employee information
emp = new Professional(5000, 15);
cout << "Type: " << emp->getType() << endl;
cout << "Weekly salary: " << emp->weeklySalary() << endl;
cout << "Health care contribution: " << emp->healthCare() << endl;
cout << "Vacation Days: " << emp->vacationDays() << endl;
cout << endl;
emp2 = new NonProfessional(20, 40, 120);
cout << "Type: " << emp2->getType() << endl;
cout << "Weekly salary: " << emp2->weeklySalary() << endl;
cout << "Health care contribution: " << emp2->healthCare() << endl;
cout << "Vacation Days: " << emp2->vacationDays() << endl;
delete emp;
delete emp2;
break;
case 12:
cout << "Exiting..." << endl;
break;
default:
cout << "Invalid choice. Please try again." << endl;
break;
}
} while (choice != 12); // Exit loop when choice is 12 (Exit)
}