-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram5_driver.cpp
More file actions
223 lines (192 loc) · 5.69 KB
/
Copy pathprogram5_driver.cpp
File metadata and controls
223 lines (192 loc) · 5.69 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#include "AirshipOrderList.h"
/*********************************************************************
void displayMenu();
Purpose:
Displays the menu of the simulation.
Parameters:
-
Return Value:
-
Notes:
-
*********************************************************************/
void displayMenu()
{
cout << "Captain, here are your options: " << endl;
cout << "1. Add a new delivery." << endl;
cout << "2. Modify an existing delivery." << endl;
cout << "3. Find a delivery." << endl;
cout << "4. Remove a delivery" << endl;
cout << "5. Display all the deliveries." << endl;
cout << "-1. Exit" << endl;
cout << "-----------------------------" << endl;
}
/*********************************************************************
File name: program5_driver.cpp
Author: Kripa Hayanju
Date: 11/12/2025
Purpose:
This program simulates the Skyborne Express Company's alien pet delivery system.
It allows the user to manage deliveries of extraterrestrial pets
using a singly linked list implemented in the AirshipOrderList class.
Users can add, modify, find, remove, and display deliveries interactively.
Command Parameters:
-
Input:
Customer name (string)
Alien pet name (string)
Quantity of pets (integer)
Total cost of delivery (double)
Menu choice (integer)
Results
Confirmation messages for each operation (add, modify, remove)
All of the information of the delivery that the user searches.
Displays an error message if the user inputs the wrong menu choice.
Notes:
The program flow is as follows:
1. Display a welcome message and list available alien pets.
2. Show the main menu with options to manage deliveries.
3. Take user input for menu selection.
4. Perform the selected operation:
- Add a delivery
- Modify an existing delivery
- Find a delivery
- Remove a delivery
- Display all deliveries
5. Loop until the user selects exit (-1).
It uses fun, creative alien pet names for simulation purposes.
*********************************************************************/
int main()
{
int iChoice;
AirshipOrderList orderList;
cout << "Welcome to Skyborne Express Company!" << endl;
cout << "Track and manage the delivery of extraterrestrial pets as they travel from one planet to another." << endl;
cout << "Available pet types for delivery: " << endl;
cout << "1. Martian Cat\n";
cout << "2. Zorp Dog\n";
cout << "3. Starling Puffer\n";
cout << "4. Glorp Pig\n";
cout << "5. Zap Bear\n \n";
cout << "Your goal is to ensure every alien pet reaches its destination safely and on time!" << endl;
while(true)
{
displayMenu();
cout << "Enter your choice: ";
cin >> iChoice;
if(iChoice == -1) //if the choice is -1
{
cout<< "Exiting the Simulation. Thank you! " << endl;
break;
}
switch(iChoice)
{
case 1: //Add delivery
{
string szN;
string szI;
int iQ;
double dC;
cin.ignore();
cout << "Enter the name of the customer: ";
getline(cin, szN);
cout << "Enter the name of the alien pet: ";
getline(cin, szI);
cout << "Enter the number of alien pets ordered: ";
cin >> iQ;
cout << "Enter the total cost of the delivery: ";
cin >> dC;
orderList.addDelivery(szN, szI, iQ, dC);
cout << "Delivery added successfully!" << endl;
cout << "-----------------------------" << endl;
break;
}
//Modify Delivery
case 2:
{
string szN;
string szI;
int iQ;
double dC;
cin.ignore();
cout << "Enter the name of the customer: ";
getline(cin, szN);
cout << "Enter the name of the alien pet: ";
getline(cin, szI);
cout << "Enter the updated number of pets: ";
cin >> iQ;
cout << "Enter the updated cost of delivery: ";
cin >> dC;
bool bDelivery = orderList.modifyDelivery(szN, szI, iQ, dC);
if(bDelivery)
{
cout << "Delivery modified successfully!" << endl;
cout << "-----------------------------" << endl;
break;
}
else
{
cout << "Could not modify delivery." << endl;
cout << "-----------------------------" << endl;
break;
}
}
//Find a delivery
case 3:
{
string szN;
string szI;
cin.ignore();
cout << "Enter the name of the customer: ";
getline(cin, szN);
cout << "Enter the name of the alien pet: ";
getline(cin, szI);
Delivery* pFound = orderList.findDelivery(szN, szI);
if(pFound != nullptr)
{
cout << "Found the delivery you were searching for!" << endl;
cout << "Customer name: " << pFound->szName << endl;
cout << "Alien pet name: " << pFound->szItem << endl;
cout << "Total number of pets purchased: " << pFound->iQuantity << endl;
cout << "Total cost of delivery: " << pFound->dCost << endl;
cout << "-----------------------------" << endl;
break;
}
else
{
cout << "Not found." << endl;
cout << "-----------------------------" << endl;
break;
}
}
case 4: //Remove the delivery
{
string szN;
string szI;
cin.ignore();
cout << "Enter the name of the customer to be removed: ";
getline(cin, szN);
cout << "Enter the name of the alien pet to be removed: ";
getline(cin, szI);
bool bRemoved = orderList.removeDelivery(szN, szI);
if(bRemoved)
{
cout << "Delivery removed successfully!" << endl;
cout << "-----------------------------" << endl;
break;
}
else
{
cout << "Could not remove the delivery." << endl;
break;
}
}
case 5: //Display the delivery
orderList.displayDeliveries();
break;
default:
cout << "Wrong choice!" << endl;
}
}
return 0;
}