Netflix allows users to create individual profiles. Within each profile, users can create a list of movies that they would like to watch in the future. This is a user's "watch list". Each watch list is stored as a linked list with each node containing the title of one movie. You will write a program which allows a user to manipulate their own watch list and to combine their watch list with that of another user on the account (ie. the watch list belonging to another profile).
Your program MUST use the implementation of linked lists as described in class that is, each node is a dictionary with two keys the data key indicates the value to be stored (the movie title) and the next key points to the next node in the list. No other data should be stored in each node other than the movie title. Object-oriented solutions or other ways of representing the linked list are not permitted.
1.We will consider 2 different lists your list (profile1) and that of profile2. The two lists are stored in two different files. Your list is stored in this file, profile1.txt. The other list is stored in this file, profile2.txt. Write a function called "readFile()" that opens a given file, reads the contents and builds a linked list from the contents. To help build the list, write a function called addToEnd which has two parameters, the head of a linked list and a data value to add (in this case, this will be the title of the movie to be stored). This function will traverse the list until it finds the end and a new node containing the specified movie will be added here. The function should return the head of the (changed) linked list. The movie titles should be stored in the same order as they are in the files.
2.Put two calls to "readFile()" in main() before your menu is created -- one call to read each file and create a list for each. These are the lines of your code that we will modify so they must be there -- and there must be 2 calls, one for each data file.
3.Provide the users with a menu that offers the following choices (and implement code that performs each operation)
Note that you should re-use code wherever possible. For instance, the first two operations can be implemented by one function. You can use the same function for displaying the list for the merge function. (It is ok to list the movies in a) and b) with numbers beside each item).
Your program should not contain any global variables. If a function manipulates one or both of the lists, they should be passed to the function as parameters.
Your program should start with a call to main() which will begin with 2 calls to "readFile" to read in the 2 data files. Next, the menu should appear allowing the user to choose from the various options.
Lets say Profile1s list consists of the following:
Elf -> Glee -> Divergent
Profile2s list is:
Ted -> Speed 2
Listing profile1s list would result in the following:
The user wishes to insert profile2s list before Glee. So, they choose 2. The merged list (ie. profile1) is:
Elf -> Ted -> Speed 2 -> Glee -> Divergent
Listing profile2 at this point would result in:
No new lists should be created after you read in the initial files. All manipulation should be done by moving the pointers of the lists. You will lose marks for creating additional lists.
Hint: Write all your functions that manipulate the lists so that you pass the list as a parameter and your return value is the head of the list. You will then call the functions like this:
myNFList = newFunction(myNFList)