Question: (((((((( C++ )))))))))) Write a simple movie ticket master system for a theater near you. The movie ticket master system should have the following functionalities
(((((((( C++ ))))))))))
Write a simple movie ticket master system for a theater near you. The movie ticket master system should have the following functionalities for die-hard movie fans to use:
View all movies
Search a movie
Purchase a movie ticket
Note: This assignment is to demonstrate how to properly use pointers to process an array. Memory allocated in this assignment are mostly static memory. Some dynamic memory is involved to allocate the MovieTicketMaster object but that's about it. You will have a chance to work with dynamic memory allocation later throughout the course.
Class Design
You need at least two classes. You're free to come up with other classes of your own if needed.
class MovieTicketMaster(minimum implementation specified below)
Private member data
Theater Name: string
Theater Location: string
An array of Movie objects (declare a global constant integer for array size and initialize it to 8. Use this variable as the size for the Movie array)
Public Constructors (it's a good programming practice to provide BOTH default and non-default constructors when defining a class)
Default constructor: set theater name and location to some default values out of your imagination
Non-default constructor: taking 2 parameters for theater name and location.
Public Destructor: output a message Theater
Public member functions:
Init:Manually initializethe entire array of Movie objects using a loop as follows:
Declare 3 arrays: array of strings (movie names), array of integers (seats available), and array of doubles (prices)
// You may need to declare a global integer variable for array size
Example:string movie_names [
"The Visit",
"Mission: Impossible - Rogue Nation",
"Straight Outta Compton",
"No Escape",
"Maze Runner: Scorch Trials",
"Everest",
"War Room",
.............................................
} ;
// Similarly declare the arrays of seats and prices. You may make up the seat and price values
// Now define a pointer to a Movie object then set it to null
// Then set the pointer to the first element in the array of Movie List
// Then define three pointers that will be used to access and iterate thru the three arrays movie_names, seats, and prices. Of course you must set them to the first element in each array accordingly
// Finally use a loop to set movie name, seats, and price for each Movie in array of Movie List as shown below. Note thatit's required to use the pointers to iterate thru the array element for all arrays. You must increment the pointers to move to the next element. Array syntax to access array element such as movie_names [i] or pointer syntax without actual pointer moving such as (p_movie + i )->set_movie_name will cause point deductions.
p_movie->set_movie_name ( .... ) ;
p_movie->set_seats ( .... );
p_movie->set_price ( ... )
Run: use a do while loop to display a menu and ask for user selection then take appropriate action (view all movies, search a movie, or purchase a ticket)
Menu: display the below
MOVIE TICKET MASTER
Theater:
// some theater advertising banner of your own: This is required!!!
View all movies
Search a movie
Purchase a ticket
Quit
ViewMovies: invoked when option 1 is chosen. Use a local pointer variable to traverse the entire array of movie objects and invoke Display function for all Movie objects
SearchMovie: invoked when option 2 is chosen. This function will ask user to input a movie name then call FindMovie (see description below). If a NULL pointer is returned by the function display an error message. Otherwise use the pointer to invoke Display function for the Movie object
FindMovie: take a parameter which is a movie name.The function is to search thru the array (using pointer to access the array, not array index notation) using linear search. If a movie is found return a pointer to the Movie object. Otherwise return a NULL pointer
PurchaseTicket: invoked when option 3 is chosen. Ask user to enter a movie name and number of tickets. Then call FindMovie and use the returned pointer to invoke PurchaseTicket function for the Movie object. Note: if the FindMovie function returns a NULL pointer output an error message stating no movie found. If the PurchaseTicket function returns -1 then display "The show has been sold out or not enough tickets available per your request.". Otherwise show the total cost to the user
class Movie
Private data members: Movie Name, Seats available, Ticket price
Constructors
Default constructor
Non-default constructor (takes 3 parameters)
Destructor: display Movie
Public member functions:
accessors and mutators for all data members
PurchaseTicket: take an integer (number of tickets) return total cost and deduct the number of seats from Seats available. If the requested numer of tickets are more than seats available return -1
Display: display all information about the movie
Implementation Requirements(missing requirements will result in points deductions)
Programmust include comments for program purpose and versions/modifications history(see ModuleWeek 1B Exercise 1). Point deduction may apply if missing this documentation requirements.
Must use member initializer syntax in constructors (see moduleWeek 1A C++ classes - The heart of OOP)
All variable names must be descriptive and follow Google coding convention. Names like x,y,z or a,b,c will be heavily penalized.
Member functions that do not modify data members must be defined asconst
Must use pointer syntax thru-out when accessing array elements or member functions. Array notation (such as MovieList[i]) or pointer notation without moving the pointer ( (p_movie+i)->set_price) is not allowed. You may need to declare more than one pointer in each function that manipulates the Movie List array
Here ishow your main program should be coded
Declare a pointer to a MovieTicketMaster object
Dynamically allocate a MovieTicketMaster object (using the non-default constructor passing theater name and theater location)
Invoke Init function using the MovieTicketMaster pointer. Now the movie ticket master has the Movie array fully loaded
Invoke Runusing the MovieTicketMaster pointer
Free memory for MovieTicketMaster object
Testing
Run the program to test all functionalities such as
View all movies
Search a movie at the beginning of the list, in the middle of the list, and at the end of the list
Search a non-existing movie
Purchase ticket:
Purchase some tickets from some movie then use Search a Movie option to verify that seats available have been properly deducted
Purchase more tickets than a movie currently has available
Purchase some ticket from a non-existing movie
Keep purchasing tickets from some movie until seats available run out
Missing test cases will result in point deductions.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
