Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MOVIES CLASS MODIFICATION- ARRAY CHANGED TO LINKED LIST Change your Movies.cpp & Movies.h files so that you no longer create an array of Movie pointers.
MOVIES CLASS MODIFICATION- ARRAY CHANGED TO LINKED LIST Change your Movies.cpp & Movies.h files so that you no longer create an array of Movie pointers. Instead, you will create a LinkedList of Movie pointers. You will only have one attribute - the linked list object which will hold Movie pointers . The constructor/destructor will need to change due to the change in attributes You will no longer need the following functions: getMaxMovies(), getMoviesArray(), getAMovieFromArray(), and resizeMovieArray() You should also rename any functions to say "List" instead of "Array" so that it makes more sense You will create two new functions . insertionSort- This function should sor thte LinkedLIst of Movies in ascending order by Movie title. This function will call a function called swap in the linkedList class to swap values in the linked list when necessary. Use the insertion sort algorithm to implement this function o o binarySearch This function should search for a particular movie title to see if it is in the list. It should return -1 if the Movie title could not be found. Remember that Movie titles are of data type Text*. Use the binary search algorithm to implement this function The addMovieToList function will need to be modified so that after this function gets the title of the movie from the user, it will check to see if this movie is already in the library (by calling binarySearch function) . If the title is not in the library, then the function will proceed to get the other movie information from the user and then add this movie to the linked list. Then, it will call the insertionSort function so that the movies are put in ascending order by title o If the title is in the library then no other information will be asked from the user and the program will print "l'm sorry! [movie title] is already in in your movie library so it will not be added again." o The readMoviesFromFile function will need to be modified so that after this function reads one movie's data from the file it will check to see if this movie is already in the library (by calling binarySearch function) If the title is not in the library, then the function will add this movie to the linked list. Then, it will call the insertionSort function so that the movies are put in ascending order by title o o If the title is in the library then the program will print "[movie title] was not added because it was already in the movie library." Then it will release the memory for the three Text objects that were unnecessarily created The getNumMovies function will need to be modified to return the number of nodes in the linked list
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started