Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello , I need help to asap write this code in C++ Task: You should create a ticket sales program for a theater with 10

Hello , I need help to asap write this code in C++ Task: You should create a ticket sales program for a theater with 10 rows and 15 seats per row. Your program should contain the theater and ticket classes (see class diagrams):

image text in transcribed

Special features of the data elements and element functions are:  The constructor of Ticket should be able to initialize the data elements row, seat, price and occupied with values taken from outside, on the other hand it should also be a standard constructor that creates an unoccupied seat (the row number row and the seat number seat have the value 0 , the ticket price the value 0.0 and the information occupied - whether the seat is occupied - the value false).  toString should return all data elements of a ticket object in a suitable formatting as a string.  The theater has 10 rows of seats and 15 seats per row, i.e. the (constant!) Class variable for the number of tickets NRT has the value 150.  The standard constructor of Theater should create an unoccupied theater whose tickets (i.e. the ticket objects in the tickets array) already contain the correct row numbers and seat numbers. In addition, the price for each ticket should be set according to the following system: The outer seats in the last row (ie seats 1 and 15 in row 10) both cost 10 euros. For each row further ahead the ticket price increases by 1 euro and at the same time the ticket price for each seat towards the center increases by 0.50 euro. The most expensive seat in the theater is therefore 8th in the first row at 22.50 euros.
 sellTicket is to process a ticket object transferred by the application program in the following way: o If the seat with the row and seat of the transferred object in the theater object is already is set, false should be returned and the transferred object should not be processed further. o If not, the occupied value of the appropriate space is set to true and also true. returned.  sortByPrice is to sort the ticket objects within the tickets array according to falling prices. The sorting method 'Selection-Sort' should be used here.  sortBySeat is to sort the ticket objects within the tickets array in ascending order by row number and within the same row by seat number. You can use a sorting method of your choice (except 'Selection-Sort', see above).  numberOfSoldTickets is to determine and return the number of tickets sold by the theater.  totalRevenues is to determine and return the total revenue of the theater in euros.  soldTickets should return all tickets sold in the theater in the form of a list of all data elements of the ticket objects as a string.  showSeats should return the theater seating plan in the format specified below as a string. An 'x' is output for an occupied seat and a '-' for a free seat.

image text in transcribed

The application program (main) should test the two classes. To do this, the following actions should take place in sequence (menu control should therefore not be implemented):  Creation of a theater object and output of the seating plan of the empty theater.  Inserting ticket objects for randomly selected seats into the theater object until a total of 50 seats are occupied. (If the selected seat is already occupied, a corresponding message should be issued and another seat selected at random).  Output of the number of tickets sold, the total income generated and the seating plan of the theater (according to the illustration above).  Output of all tickets sold in the form of a list sorted according to the ticket price.  Then: Output of all tickets sold in the form of a list sorted by row and seat.
Ticket Theatre + NRT: int tickets: array + Theatre () + sellTicket (Ticket): bool + sortByPrice (): void + sortBySeat(): void + numberOfSoldTickets (): int + totalRevenues (): double + soldTickets (): string + showSeats (): string row: int seat: int - price: double occupied: bool + Ticket(int,int, double, bool) + toString(): string + Verkaufte Tickets: 50 Gesamteinnahmen: 812.50 Euro Saalplan: 1 2 3 4 5 6 7 8 9 10 11 12 1 x X 13 14 15 - - X X X X x X - x x X X x X Oo Oo vou A WN | | | | * 1 1 x X 1 * 1 x x X x X x X x | * * * 1 X | | x X x X x x Ticket Theatre + NRT: int tickets: array + Theatre () + sellTicket (Ticket): bool + sortByPrice (): void + sortBySeat(): void + numberOfSoldTickets (): int + totalRevenues (): double + soldTickets (): string + showSeats (): string row: int seat: int - price: double occupied: bool + Ticket(int,int, double, bool) + toString(): string + Verkaufte Tickets: 50 Gesamteinnahmen: 812.50 Euro Saalplan: 1 2 3 4 5 6 7 8 9 10 11 12 1 x X 13 14 15 - - X X X X x X - x x X X x X Oo Oo vou A WN | | | | * 1 1 x X 1 * 1 x x X x X x X x | * * * 1 X | | x X x X x x

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions