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 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
|
using namespace std;
const int ROWS = 9;
const int COLUMNS = 10;
int display_menu();
int display_seating_chart();
int seat_by_price(int);
int seating_chart[ROWS][COLUMNS] =
{
{ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
{ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
{ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
{ 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
{ 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
{ 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
{ 20, 20, 30, 30, 40, 40, 30, 30, 20, 20 },
{ 20, 30, 30, 40, 50, 50, 40, 30, 30, 20 },
{ 30, 40, 50, 50, 50, 50, 50, 50, 40, 30 },
};
int main()
{
int quit = 0;
cout << "\n~~~~~~~~~~~~ Welcome to the Theatre! ~~~~~~~~~~~~~\n\n";
cout << "Tickets prices range from $10, $20, $30, $40, and $50";
cout << "\nNo tickets have been sold yet. All seats are available.\n\n";
display_seating_chart();
do
{
display_menu();
int choice;
cin >> choice;
int temp_row;
int temp_seat;
switch (choice)
{
case 1: cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
cout << "These are the seats that are currently available. Seats with '0' have already been sold.\n";
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n";
display_seating_chart(); system("pause"); break;
case 2: int choose; cout << "------------------\n1) Specific seat\n2) Any seat by $\n------------------\n";
cout << "Please choose how you would like to purchase your ticket: ";
cin >> choose;
cout << "------------------------------------------------------------\n";
if (choose == 2)
{
int ticket_by_price;
bool found = false;
int pos = 0;
cout << "Please choose how much you want to spend on your ticket.\nTickets cost $10, $20, $30, $40, and $50.\n";
cout << "------------------------------------------\n$";
cin >> ticket_by_price;
while (pos < 90 && !found)
{
if (seating_chart[pos][pos] == ticket_by_price)
{
found = true;
}
else
{
pos++;
}
}
if (!found)
{
cout << "Sorry, there are no more seats available for that price.\n";
}
ticket_by_price = seat_by_price(ticket_by_price);
}
else
{
cout << "Please choose a valid option:\n";
}
system("pause"); break;
case 3: cout << "Thank you for using this program!\n"; quit = -1; break;
}
} while (quit != -1);
system("pause");
return 0;
}
int display_menu()
{
cout << "\nMovie Theatre Menu\n";
cout << "----------------------\n";
cout << "1) Show seating chart\n";
cout << "2) Purchase tickets\n";
cout << "3) Quit the program\n";
cout << "----------------------\n";
cout << "Please enter what you would like to do: ";
return 0;
}
int display_seating_chart()
{
//Seats header
for (int seats_header = 0; seats_header < 11; seats_header++)
{
if (seats_header == 0)
{
cout << "Seats| ";
}
else if (seats_header < 2)
{
cout << setw(3) << seats_header;
}
else if (seats_header < 11)
{
cout << setw(4) << seats_header;
}
}
cout << endl;
for (int seats_header = 0; seats_header < 11; seats_header++)
{
if (seats_header < 11)
{
cout << "====";
}
}
cout << "====" << endl;
//Rows
for (int row = 0; row < ROWS; row++)
{
switch (row)
{
case 0: cout << "Row 1| "; break;
case 1: cout << "Row 2| "; break;
case 2: cout << "Row 3| "; break;
case 3: cout << "Row 4| "; break;
case 4: cout << "Row 5| "; break;
case 5: cout << "Row 6| "; break;
case 6: cout << "Row 7| "; break;
case 7: cout << "Row 8| "; break;
case 8: cout << "Row 9| "; break;
}
// Seating Chart Array
for (int column = 0; column < COLUMNS; column++)
{
cout << setw(2) << seating_chart[row][column] << " ";
}
cout << endl;
}
return 0;
}
int seat_by_price(int ticket_by_price)
{
switch (ticket_by_price)
{
case 10:
for (int row = 0; row < 9; row++)
{
for (int column = 0; column < 10; column++)
{
if (seating_chart[row][column] == 10)
{
seating_chart[row][column] = 1;
cout << "Seat " << column + 1 << ", in Row " << row + 1 << ", is available for $10\n";
cout << "--------------------------------------\nPurchase was successful\n";
return seating_chart[row][column] = 0;
}
}
}
break;
case 20:
for (int row = 0; row < 9; row++)
{
for (int column = 0; column < 10; column++)
{
if (seating_chart[row][column] == 20)
{
seating_chart[row][column] = 2;
cout << "Seat " << column + 1 << ", in Row " << row + 1 << ", is available for $20\n";
cout << "--------------------------------------\nPurchase was successful\n";
return seating_chart[row][column] = 0;
}
}
}
break;
case 30:
for (int row = 0; row < 9; row++)
{
for (int column = 0; column < 10; column++)
{
if (seating_chart[row][column] == 30)
{
seating_chart[row][column] = 3;
cout << "Seat " << column + 1 << ", in Row " << row + 1 << ", is available for $30\n";
cout << "--------------------------------------\nPurchase was successful\n";
return seating_chart[row][column] = 0;
}
}
}
break;
case 40:
for (int row = 0; row < 9; row++)
{
for (int column = 0; column < 10; column++)
{
if (seating_chart[row][column] == 40)
{
seating_chart[row][column] = 4;
cout << "Seat " << column + 1 << ", in Row " << row + 1 << ", is available for $40\n";
cout << "--------------------------------------\nPurchase was successful\n";
return seating_chart[row][column] = 0;
}
}
}
break;
case 50:
for (int row = 0; row < 9; row++)
{
for (int column = 0; column < 10; column++)
{
if (seating_chart[row][column] == 50)
{
seating_chart[row][column] = 5;
cout << "Seat " << column + 1 << ", in Row " << row + 1 << ", is available for $50\n";
cout << "--------------------------------------\nPurchase was successful\n";
return seating_chart[row][column] = 0;
}
}
}
break;
}
return 0;
}
|