Question: C++ programming assignment using classes etc. Goal: Your assignment is to write a C++ program to implement the ADT List by creating a list of
C++ programming assignment using classes etc.

Goal: Your assignment is to write a C++ program to implement the ADT List by creating a list of movies. This assignment will help you practice: multiple file programming, classes, public and private methods, dynamic memory, constructors and destructors, arrays and files Implementation This lab assignment gives you the opportunity to practice creating classes and using dynamic memory in one of the required classes There are two classes to implement: Movie and MovieList. As you can see in the description table, MovieList has movies, a list of Movie objects modeled using an array of Movie (pointers to Movie) Each Movie object will be dynamically created when it is added to the list if it is possible to add them (the list might be full, or the insert position invalid) You will create the following files movie.h movie.cpp movielist.h movielist.cpp contains the Movie class declaration contains the Movie class method definitions contains the Movie class declaration contains the Movie class method definitions You are not turning in a main() for this program. You will compile, run, and test your program using the unit test. You are strongly encouraged to start by writing Movie and ensuring all relevant unit tests pass before moving on to MovieList. Only the unit test will be used for grading The following table explains each of the methods that you will need to implement Class Access Private Member Description Title of the movie, there can be spaces in the title Private _genre Genre of the movie, there can be spaces in the enre Year the movie was first released in theaters Private year Public Movie( Constructor that takes in the title, the genre const string& title,and the year for a movie. Notice that there is const string& genre, NO default constructor size t year) Public Movie(const Movie&) PublicWrite( ostream&, bool - Copy constructor Writes the movie to the output stream in the parameter. Prints a formatted output if the bool parameter is true (30 columns for title, 15 for genre, 6 for year); prints unformatted output if the bool is false (one field per line) Reads a movie from an input stream, the fields are separated by end line Returns the title of the movie Returns the genre of the movie Returns the year of the movie Movie false): void Public Read (istream&): void PublicGetTitle(): string Public GetGene): string Public etYear): size t Public Equals (const Movie&): bool Compares two movies for equality; returns true if title, genre, and year match exactly, false otherwise Class Access Member Description Global const size t MAX-MOVIES 10 | Maximum number of movies that the movie list can store, it will also be the size of the array of Movies PrivateMovie movies [MAX MOVIES] Array of pointers to Movie. Each position of the array will point to a dynamically allocated Movie when the movie is added Stores the number of movies that are actually. added to the array. When the array is empty Private size t _size ize has value zero Private MovieList(const Movielist&)Copy constructor. Note this is private PublicMovieist() Default constructor, sets the number of movies to zero, and initializes the array elements to nullptr Frees the memory by releasing all the dynamically created movies in the array. DO NOT try to delete the actual array since it was not d Adds a movie to a position in the array specified by the size t parameter. The Public -m0yaeldst() ically created. PublicInsert(_const Movie&, size t): bool position must not exceed_size. A movie may be inserted at the end of the array or any previous element, in which case later elements in the array are shifted to the right. Returns true if it was possible to add the movie, false otherwise If the position is valid, it removes the movie in that position from the arrav. This should free memory allocated for the movie and ensure the array does not have any gaps -- all movies in the array from position 0 to_size - 1 should be valid movies MovieList PublicRemove(size t): bool Public Index (const Movie&): intReturns the position of the movie parameter in the array, if it exists, and -1 if the movie is not contained in the array If the position is valid, it returns the pointer to the movie in that position, returns nullptr otherwise Clear the array of movies. Make sure to free memory allocated for each movie Returns the number of movies in the array Returns true if the array is empty, false otherwise PublicGet (size t): Movie* Public Clear() void Public Size): sizet PublicIsEmpty(): bool Goal: Your assignment is to write a C++ program to implement the ADT List by creating a list of movies. This assignment will help you practice: multiple file programming, classes, public and private methods, dynamic memory, constructors and destructors, arrays and files Implementation This lab assignment gives you the opportunity to practice creating classes and using dynamic memory in one of the required classes There are two classes to implement: Movie and MovieList. As you can see in the description table, MovieList has movies, a list of Movie objects modeled using an array of Movie (pointers to Movie) Each Movie object will be dynamically created when it is added to the list if it is possible to add them (the list might be full, or the insert position invalid) You will create the following files movie.h movie.cpp movielist.h movielist.cpp contains the Movie class declaration contains the Movie class method definitions contains the Movie class declaration contains the Movie class method definitions You are not turning in a main() for this program. You will compile, run, and test your program using the unit test. You are strongly encouraged to start by writing Movie and ensuring all relevant unit tests pass before moving on to MovieList. Only the unit test will be used for grading The following table explains each of the methods that you will need to implement Class Access Private Member Description Title of the movie, there can be spaces in the title Private _genre Genre of the movie, there can be spaces in the enre Year the movie was first released in theaters Private year Public Movie( Constructor that takes in the title, the genre const string& title,and the year for a movie. Notice that there is const string& genre, NO default constructor size t year) Public Movie(const Movie&) PublicWrite( ostream&, bool - Copy constructor Writes the movie to the output stream in the parameter. Prints a formatted output if the bool parameter is true (30 columns for title, 15 for genre, 6 for year); prints unformatted output if the bool is false (one field per line) Reads a movie from an input stream, the fields are separated by end line Returns the title of the movie Returns the genre of the movie Returns the year of the movie Movie false): void Public Read (istream&): void PublicGetTitle(): string Public GetGene): string Public etYear): size t Public Equals (const Movie&): bool Compares two movies for equality; returns true if title, genre, and year match exactly, false otherwise Class Access Member Description Global const size t MAX-MOVIES 10 | Maximum number of movies that the movie list can store, it will also be the size of the array of Movies PrivateMovie movies [MAX MOVIES] Array of pointers to Movie. Each position of the array will point to a dynamically allocated Movie when the movie is added Stores the number of movies that are actually. added to the array. When the array is empty Private size t _size ize has value zero Private MovieList(const Movielist&)Copy constructor. Note this is private PublicMovieist() Default constructor, sets the number of movies to zero, and initializes the array elements to nullptr Frees the memory by releasing all the dynamically created movies in the array. DO NOT try to delete the actual array since it was not d Adds a movie to a position in the array specified by the size t parameter. The Public -m0yaeldst() ically created. PublicInsert(_const Movie&, size t): bool position must not exceed_size. A movie may be inserted at the end of the array or any previous element, in which case later elements in the array are shifted to the right. Returns true if it was possible to add the movie, false otherwise If the position is valid, it removes the movie in that position from the arrav. This should free memory allocated for the movie and ensure the array does not have any gaps -- all movies in the array from position 0 to_size - 1 should be valid movies MovieList PublicRemove(size t): bool Public Index (const Movie&): intReturns the position of the movie parameter in the array, if it exists, and -1 if the movie is not contained in the array If the position is valid, it returns the pointer to the movie in that position, returns nullptr otherwise Clear the array of movies. Make sure to free memory allocated for each movie Returns the number of movies in the array Returns true if the array is empty, false otherwise PublicGet (size t): Movie* Public Clear() void Public Size): sizet PublicIsEmpty(): bool
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
