Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need MovieList class part, no main needed. The following table explains each of the methods that you will need to implement. Goal: Your assignment is

Need MovieList class part, no main needed.

image text in transcribed

The following table explains each of the methods that you will need to implement.

image text in transcribed

image text in transcribed

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 contains the Movie class declaration contains the Movie class method definitions contains the Movie class declaration contains the Movie class method definitions movielist.h - movielist.cpp Class Access Private Member Description title Title of the movie, there can be spaces in the title. Private _genre Genre of the movie, there can be spaces in the Private_ Public enre. Year the movie was first released in theaters Constructor that takes in the title, the genre, _year Movie 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&) Public Write(_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 false): void Movie Public Read(istream&): void PublicGetTitle(): string Public tGenre): string Public GetYear): sizet Public Equals(const Movie): boolCompares two movies for equality; returns true if title, genre, and year match exactly, false otherwise. Class Access Global const size t MAX_MOVIES10 Maximum number of movies that the movie Member Description list can store, it will also be the size of the array of Movie:s Private Movie*_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 size has value zero Private Movielist(const MovieList&) Copy constructor. Note this is private. Public Movieist) 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 Public Movietist() no ically created PublicInsert(_const Movie&, size t) bool Adds a movie to a position in the array specified by the size t parameter. The 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 array. 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 Public Reove (size t): bool PublicIndexof(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 Public Get(size t: Movie* PublicClear(): void Public Size(): size-t Public IsEmpty): bool

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

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

Stakeholders' power over businesses stems from their

Answered: 1 week ago