Defining the Class Theater Define and implement a class Theater as described in the diagram and text
Question:
Defining the Class Theater
Define and implement a class Theater as described in the diagram and text below.
Theater
Private
(-) TheaterId Type: string
(-) TheaterName Type: string
(-) noOfBookedSeats Type: int
(-) visitors Type: array of 50 string
Public
(+) defaulted initializer constructor (string id, string name)
(+) copy constructor
(+) string getTheaterid ()
(+) string getTheaterName()
(+) string getVisitor(int position)
(+) void addBooking(string name)
(+) void deleteBooking(string name)
(+) bool isThereEmptySpace()
(+) int getNumberofBookedSeats()
(+) bool HasMoreVisitors(Theater &c2)
(+) int HasSameVisitors (Theater &c2)
(+) void print()
(+) destructor
Define a global variable of type integer called Size and initialize it to 50 and use it to control the size of the array in the class.
Data Members:
o The TheaterId data member is the Theater ID.
o The TheaterName data member is a string variable that represents the Theater name.
o The noOfBookedSeats data member is an integer that represents the number of Visitors in the Theater object.
o The visitors data member is an array of 50 elements of string that represents the name of
3
visitors.
Member functions
o Defaulted Initializer constructor (String d, string n)
1) Sets TheaterId to d, name to n, noOfBookedSeats to zero, visitors all set to “N/A” . Validate the TheaterName and TheaterID to be not empty.
2) The default values of the TheaterId is “1”, TheaterName is “Theater”.
o Copy constructor.
o getTheaterid(): that returns the Theater Id.
o getVisitor (int position): that return the visitor name in index position.
o void addBooking(string name): which checks if there is space in the Theater and then add the visitor to the Theater. Increase booked seats. Write the appropriate cout messages.
o void deleteBooking(string name): which checks if the visitor already reserved a seat in a Theater and if yes delete the booking and shift all the bookingd in the visitors array. Write the appropriate cout messages
o bool isThereEmptySpace(): that return true if the Theater has empty seats and return false if there are no empty seats.
o getNumberofBookedVisitors (): that return the number of visitors in the current Theater.
o bool HasMoreVisitors (Theater &c2): that compares the current Theater object with the given Theater object c2, if the current Theater object has more visitors then return true, otherwise return false.
o int HasSameVisitors (Theater &c2): that compares the current Theater object with the given Theater object c2, and returns how many common visitors have reserved seats in both Theater objects.
o void print(): which prints the details of the Theater object: Theater ID, Theater Name, and number of booked seats.
o destructor: that print a goodbye message for the Theater visitors
“Theater TheaterName is closed
College Physics
ISBN: 978-0495113690
7th Edition
Authors: Raymond A. Serway, Jerry S. Faughn, Chris Vuille, Charles A. Bennett