-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram6_driver.cpp
More file actions
175 lines (154 loc) · 4.28 KB
/
Copy pathprogram6_driver.cpp
File metadata and controls
175 lines (154 loc) · 4.28 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#include "program6.h"
/*********************************************************************
void displayMenu(string szMenuName, string szChoicesArr[], int iChoices)
Purpose:
Function to display the menu choices of a provided menu
Parameters:
I string szMenuName Title of the displayed menu
I string szChoicesArr Menu choices to be displayed
I int iChoices Number of menu choices
Return Value:
-
Notes:
Menu options are displayed starting at 1
The last menu option should always be displayed as -1
*********************************************************************/
void displayMenu(string szMenuName, string szChoicesArr[], int iChoices)
{
cout << szMenuName << endl;
int i;
cout << szBreakMessage;
for(i = 0; i < iChoices - 1; i = i + 1)
{
cout << i+1 << ". " << szChoicesArr[i] << endl;
}
cout << "-1. " << szChoicesArr[i] << endl;
cout << szBreakMessage << endl;
}
/*********************************************************************
File name: program6_driver.cpp
Author: Kripa Hayanju, Nikasha Pokharel
Date: 11/29/2025
Purpose:
Program driver for program 6.
Command Parameters:
-
Input:
Various menu options
Results:
-
Notes:
This does not validate any input
*********************************************************************/
int main()
{
TrainQueue train;
MaintenanceStack maintenance;
string szMenuName = "\nRailway Station Management System";
string szMenuChoicesArr[9] =
{
"Add a new train departure",
"View the next train",
"Process the next train",
"Clear train departures",
"File a new maintenance request",
"View the latest maintenance request",
"Resolve the latest maintenance request",
"Clear maintenance requests",
"Exit"
};
int iChoice;
do
{
displayMenu( szMenuName, szMenuChoicesArr, 9);
cout << "Select an option: ";
cin >> iChoice;
switch (iChoice)
{
case 1:
{
int iNum, iPassengers;
string szDest, szTime;
cout << "Enter train number: ";
cin >> iNum;
cin.ignore();
cout << "Enter destination: ";
getline(cin, szDest);
cout << "Enter departure time: ";
getline(cin, szTime);
cout << "Enter passenger count: ";
cin >> iPassengers;
train.enqueueTrain(iNum, szDest, szTime, iPassengers);
cout << "Train added to queue." << endl;
break;
}
case 2:
{
cout << "Peeking the next train: " << endl;
train.peekTrain();
break;
}
case 3:
{
cout << "Processing the next train: " << endl;
cout << train.dequeueTrain() << endl;
break;
}
case 4:
{
while(!train.isEmpty())
{
train.dequeueTrain();
}
cout << "Emptying train queue" << endl;
break;
}
case 5:
{
int iR;
string szI, szR;
cout << "Enter maintenance request number: ";
cin >> iR;
cin.ignore();
cout << "Enter maintenance issue: ";
getline(cin, szI);
cout << "Enter staff reporter name: ";
getline(cin, szR);
maintenance.pushRequest(iR, szI, szR);
cout << "Maintenance request added to stack." << endl;
break;
}
case 6:
{
cout << "Peeking the latest maintenance request: " << endl;
maintenance.peekRequest();
break;
}
case 7:
{
cout << "Resolving the latest maintenance request: " << endl;
cout << maintenance.popRequest() << endl;
break;
}
case 8:
{
while(!maintenance.isEmpty())
{
maintenance.popRequest();
}
cout << "Cleared maintenance requests." << endl;
break;
}
case -1:
{
cout << "Exiting program." << endl;
break;
}
default:
{
cout << "Invalid Choice. Try again." << endl;
}
}
} while (iChoice != -1);
return 0;
}