Purchase Solution

Simple seat reservation system for a theater

Not what you're looking for?

Ask Custom Question

Implement a simple seat reservation system for a theater in C++. The seats in the theater will be represented with a two dimensional array. The closer the seats are to the stage, the more expensive the seats are. Moreover, within a row, the seats at the center shall be more expensive.

Use a simple algorithm to assign costs to seats. The seats in one row cost $10 more than the seats in the previous row. Within a row of n seats, the first and last n/4 seats should be $5 cheaper than the rest of the seats.

The following charts are examples of the expected costs of seats:

40 45 45 40
30 35 35 30
20 25 25 20
10 15 15 10

To do so, create a class TheaterReservationSystem having the following members:

A constructor taking two int constants: rows and seatsPerRow.

A function member int computeCost(int row, int seat). This function will calculate the cost of the seat based on the row and seat number as described above.

A function member bool reserveSeat(int cost). This function will reserve the first available seat of the specified cost if there is one. If the program finds a seat of the specified cost, the function shall return true. Otherwise, the function shall return false.

A function member bool reserveBestSeat(int lowestCost, int highestCost). This function will reserve the best seat available within the specified cost range. One seat is considered better than another if either it is closer to the stage or it is in the same row but in the center of the row.

A function member void displaySeatsCost(). This function will print to the standard output a matrix containing the cost of the seats.

A function member void displaySeats(). This function will print to the standard output a matrix showing which seats are reserved and which seats are not.

A data member m_seats of type bool[][].

Create a driver file TheaterReservationDriver. In this file create two constants int: seats and seatsPerRow. Upon executing the driver, it will create an object TheaterReservationSystem passing seats and seatsPerRow to its constructor. The program shall display the following menu:

Enter 1 to reserve a seat

Enter 2 to reserve the best seat available

Enter 3 to display seats cost

Enter 4 to display reservations

Option 1 will prompt the user for a cost and it will invoke function reserveSeat. Option 2 will prompt the user for a cost range and it will invoke function reserveBestSeat. These two options shall display an appropriate message indicating whether the reservation could be made or not. Options 3 and 4 will invoke displaySeatCost and displaySeats respectively.

Purchase this Solution

Solution Summary

Code contains detailed comments to explain the logic used in there. It has been tested using GNU C++ compiler version 4.3.4 . Please use this response only as a guidance to help you develop a solution in your own style.

Solution Preview

Please go through the attached 474468.cpp and understand it thoroughly. Code has been tested with 4x4 theater arrangement as given in the ...

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.