Question: So I have a code that works for the assignment below by creating a cart of |#| and |~| for full and empty seats. What
So I have a code that works for the assignment below by creating a cart of |#| and |~| for full and empty seats. What I want to do is another chart similar to the other one that shows the price for each seat in the chart. Is this possible? I have tried but can't get it to work. My code is below the assignment and is split into different classes
The program should use separated classes. Write a program that can be used by a small theater to sell tickets for performances. The theaters auditorium has 15 rows of seats, with 15 seats in each row. The program should display a screen that shows which seats are available and which are taken. For example, the following screen shows a chart depicting each seat in the theater. Seats that are taken are represented by an ~ symbol, and seats that are available are presented by a # symbol:

Here is a list of tasks this program must perform: When the program begins, it should ask the user to enter the seat prices for each row. The prices can be stored in a separate array. (Alternatively, the prices may be read from a file.) Once the prices are entered, the program should display a seating chart similar to the one shown above. The user may enter the row and seat numbers for tickets being sold. Every time a ticket or group of tickets is purchased, the program should display the total ticket prices and update the seating chart. The program should keep a total of all ticket sales. The user should be given an option of viewing this amount. The program should also give the user an option to see a list of how many seats have been sold, how many seats are available in each row, and how many seats are available in the entire auditorium. Input validation: when tickets are being sold, do not accept row or seat numbers that do not exist. When someone requests a particular seat, the program should make sure that seat is available before it is sold.
Thearter .h
#pragma once
#include
#include
using namespace std;
class Theater {
public:
Theater();
void displaySeat();
void setPrice();
void options();
void purchase(int, int);
bool isFull(int, int);
private:
double seatprice[15][15];
double price[15];
string seat[15][15];
int totalbooked = 0;
int totalavailable = 225;
};
Thearter.cpp
#include "theater.h"
Theater::Theater() {
for (int i = 0; i
{
for (int j = 0; j
seat[i][j] = "|#|";
}
}
}
void Theater::displaySeat() {
cout
for (int a = 0; a
cout
}
for (int a = 10; a
cout
}
cout
for (int i = 0; i
cout
for (int j = 0; j
cout
}
cout
}
}
void Theater::setPrice() {
for (int a = 0; a
cout
cin >> price[a];
for (int j = 0; j
seatprice[a][j] = price[a];
}
}
}
void Theater::options() {
int numfull = 0;
int row;
int totalcost = 0;
int option;
int seatnum;
bool start = true;
while (start == true) {
cout
cout
cout
cout
cout
cout
cout
cin >> option;
switch (option){
case 1:
for (int i = 0; i
cout
}
cout
break;
case 2:
while (true) {
cout
cin >> row;
if (row = 1) {
cout
cout
cin >> seatnum;
if (seatnum 0) {
if (isFull(row - 1, seatnum - 1)) {
cout
}
else {
purchase(row - 1, seatnum - 1);
cout
displaySeat();
++totalbooked;
totalcost += price[row - 1];
cout
}
}
else {
cout
}
}
else {
cout
}
char c;
cout
cin >> c;
if (c != 'y') {
break;
}
cout
cout
}
break;
case 3:
int r;
numfull = 0;
cout
cin >> r;
if (r >= 1 && r
for (int j = 0; j
if (seat[r - 1][j] == "|~|") {
++numfull;
}
}
cout
}
else {
cout
}
break;
case 4:
int r2;
cout
cin >> r2;
if (r2 >= 1 && r2
cout
}
else {
cout
}
break;
case 5:
cout
break;
case 6:
cout
break;
case 7:
start = false;
break;
default:
cout
break;
}
}
}
void Theater::purchase(int rownum, int setnum) {
seat[rownum][setnum] = "|~|";
}
bool Theater::isFull(int row, int col) {
if (seat[row][col] == "|~|")
return true;
return false;
}
source.cpp
#include
#include "theater.h"
int main() {
Theater t;
t.setPrice();
t.displaySeat();
t.options();
return 0;
}
Thank you!!!!
1#1 1#1 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
