-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmovie_simulation_program_3.cpp
160 lines (142 loc) · 5.46 KB
/
movie_simulation_program_3.cpp
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
#include "movie_simulation_program_3.h"
/*********************************************************************
File name: movie_simulation_program_3.cpp
Author: David Patrick
Date: 03/31/24
Purpose:
Extend the movie theater simulation from program 2.
Command Parameters:
-
Input:
Path to theater text files.
Various user input menu choices and ticket purchases.
Results:
Simulates a drive-in movie theater ticket booth.
Notes:
-
*********************************************************************/
int main()
{
fstream fileTheaterInput;
fstream fileDataIO;
string szTheaterName;
string szAdminPassword = "cars";
string szTemp;
int iAttempts = 0;
string szDefaultMenuChoicesArr[6] = {
"Display theater information",
"Display now showing",
"Buy tickets",
"Refund tickets",
"Admin Menu",
"Exit program"
};
string szAdminMenuChoicesArr[7] = {
"Update theater information",
"Display total sales",
"Clear data",
"Store data",
"Load data",
"Update admin password",
"Exit admin menu"
};
cout << "Starting movie theater simulation\n" << endl;
Theater driveInTheater;
processTheaterInformation(fileTheaterInput, driveInTheater);
int iChoice;
int iAdminChoice;
do
{
displayMenu("\nMenu", szDefaultMenuChoicesArr, 6);
cout << "\nEnter choice: ";
cin >> iChoice;
switch(iChoice)
{
case 1:
displayTheaterInfo(driveInTheater);
break;
case 2:
displayNowShowing(driveInTheater);
break;
case 3:
driveInTheater.customersArr[driveInTheater.iCurrentCustomers] = buyTickets(driveInTheater);
if(driveInTheater.customersArr[driveInTheater.iCurrentCustomers].szName != "")
driveInTheater.iCurrentCustomers += 1;
break;
case 4:
refundTickets(driveInTheater);
break;
case 5:
cout << "Enter admin password: ";
cin.ignore();
cin >> szTemp;
if(szTemp == szAdminPassword)
{
cout << "Admin access granted" << endl;
iAttempts = 0;
do
{
displayMenu("\nAdmin Menu", szAdminMenuChoicesArr, 7);
cout << "\nEnter choice: ";
cin >> iAdminChoice;
switch(iAdminChoice)
{
case 1:
cin.ignore();
processTheaterInformation(fileTheaterInput, driveInTheater);
break;
case 2:
calculateTotalSales(driveInTheater);
cout << "Today's total sales is $" << calculateTotalSales(driveInTheater) << endl;
break;
case 3:
cout << "What data would you like to clear (Customers/Members): ";
cin >> szTemp;
clearData(driveInTheater, szTemp);
break;
case 4:
cout << "What data would you like to store (Customers/Members): ";
cin >> szTemp;
storeData(driveInTheater, fileDataIO, szTemp);
break;
case 5:
cout << "What data would you like to load (Customers/Members): ";
cin >> szTemp;
loadData(driveInTheater, fileDataIO, szTemp);
break;
case 6:
cout << "Please enter new admin password: ";
cin.ignore();
getline(cin, szAdminPassword);
cout << "Password has been updated" << endl;
case -1:
cout << "Exiting admin menu" << endl;
iAdminChoice = -1;
break;
default:
cout << "Please choose a valid menu choice" << endl;
}
}while(iAdminChoice != -1);
}
else
{
cout << "Incorrect password." << endl;
iAttempts += 1;
if(iAttempts > 3)
{
cout << "Closing program due to excess password attempts." << endl;
return -1;
}
}
break;
// Exit the program
case -1:
cout << "Exiting program" << endl;
break;
// Default case handling
default:
cout << "Please choose a valid menu choice" << endl;
}
}while(iChoice != -1);
return 0;
}