The overall goal of this assignment is to implement a C++ application that mimics some of Netflix's functionality. This application will store movies and keep track of the year they were released, their rating and their ranking. In this assignment you will refresh your knowledge of control structures, functions, pointers, sorting, dynamic memory management, operator overloading, and exceptions. Additionally, you will be implementing your own DoublyLinkedList which will be a subset of the C++ STL list. After completion you should feel more comfortable with allocating memory on the heap to create more complex data structures. Specifically, you will learn how to link different objects in the heap together and to bi-directionally traverse through these objects in memory. see image.
In the end, you will be storing movie information in this list and sorting it.
The following requirements are an overview of what is expected of you in this assignment. More details on how to implement the solution can be found in the Technical Requirements section.
The following snippet is pseudocode for the insertion sort algorithm:
for i <- 1 to length(A)-1
j <- i
while j > 0 and A[j-1] > A[j]
swap A[j] and A[j-1]
j <- j i 1
end while
end for
Which behaves as presented below: see image.
For more information on insertion sort check this video.
1. Download the starter file set. It will contain the following files:
catch.hpp
DoublyLinkedlist.hpp
Movie.hpp
main.cpp
2. The provided main.cpp file is the test file. You are free to test your own program using your own main.cpp file but bear in mind that you will be tested against the provided one.
3. The provided DoublyLinkedlist.hpp and Movie.hpp files contain all of the function prototypes of the functions that are going to be tested. You are free to add any others as you wish. Your main task is to write the C++ implementation code for each of these functions.
4. Use your favorite IDE or editor to modify your files. At first, the program won't compile because the functions' implementation are missing.
5. In DoublyLinkedlist.hpp, write an empty implementation for each of the functions specified.
6. Create a Movie.cpp file and write an empty implementation for each of the functions specified.
7. The program will now compile. If you try running the program it will tell you that it has failed all the tests. Your goal is to make the program pass all the tests by completing the implementation of the methods given to you. You can implement helper functions if needed. See the following section for more information.
This section will serve as a guideline of what is necessary for the program to pass all the tests. We perform unit testing using the Catch framework. Catch is a header-only framework which means you just need to drop the header file containing the framework into your project. This is the reason behind the catch.hpp file.
You can also see that some code is provided in the main.cpp file. This code tests the functions in your program. If your code passes all the tests it is ready for submission and will, most likely (cheating is heavily penalized), receive full credit.
Don't change the function signatures as the testing program relies on this to grade your submission.
Let's start explaining what each of the functions in the Movie class must do:
Movie movie1("A", 2010, "PG", 1);
Movie movie2("B", 2011, "PG-13", 5);
Movie movie3("C", 2012, "PG", 4);
Movie movie1("A", 2010, "PG", 1);
movie1.getName();
Movie movie1("A", 2010, "PG", 1);
movie1.getRating();
Movie movie1("A", 2010, "PG", 1);
movie1.getYear();
Movie movie1("A", 2010, "PG", 1);
movie1.getRanking();
Movie movie1("A", 2010, "PG", 1); movie1.setName("A2").setYear(2011).setRating("PG").setRanking(2);
Movie movie1("A", 2010, "PG", 1); movie1.setName("A2").setYear(2011).setRating("PG").setRanking(2);
Movie movie1("A", 2010, "PG", 1);
movie1.setName("A2").setYear(2011).setRating("PG").setRanking(2);
Movie movie1("A", 2010, "PG", 1); movie1.setName("A2").setYear(2011).setRating("PG").setRanking(2);
Movie movie1("A", 2010, "PG", 1);
Movie movie2("B", 2011, "PG-13", 5);
Movie movie3("C", 2012, "PG", 4);
bool result = (moviel == movie2);
Movie movie1("A", 2010, "PG", 1);
Movie movie2("B", 2011, "PG-13", 5);
Movie movie3("C", 2012, "PG", 4);
bool result = (movie1 < movie2);
Movie moviel("A", 2010, "PG", 1);
Movie movie2("B", 2011, "PG-13", 5);
Movie movie3("C", 2012, "PG", 4);
bool result = (moviel <= movie2);
Movie movie1("A", 2010, "PG", 1);
Movie movie2("B", 2011, "PG-13", 5);
Movie movie3("C", 2012, "PG", 4);
bool result = (moviel > movie2);
Movie movie1("A", 2010, "PG", 1);
Movie movie2("B", 2011, "PG-13", 5);
Movie movie3("C", 2012, "PG", 4);
bool result = (movie1 >= movie2);
Let's start explaining what each of the functions in the DoublyLinkedlist class must do:
DoublyLinkedList< Movie> list;
list.size();
list.isEmpty();
Movie movie1("A", 2010, "PG", 1);
Movie movie2("B", 2011, "PG-13", 5);
Movie movie3("C", 2012, "PG", 4);
Movie movie4("D", 2013, "R", 3);
DoublyLinkedList< Movie> list;
list.insert(moviel);
list.insert(movie2);
list.insert(movie3);
list.insert(movie4);
Movie movie1("A", 2010, "PG", 1);
Movie movie2("B", 2011, "PG-13", 5);
Movie movie3("C", 2012, "PG", 4);
Movie movie4("D", 2013, "R", 3);
DoublyLinkedList< Movie> list;
list.insert(movie1);
list.insert(movie2);
list.insert(movie3);
list.insert(movie);
list.find(movie1);
Movie movie1("A", 2010, "PG", 1);
Movie movie2("B", 2011, "PG-13", 5);
Movie movie3("C", 2012, "PG", 4);
Movie movie4("D", 2013, "R", 3);
DoublyLinkedList< Movie> list;
list.insert(movie1);
list.insert(movie2);
list.insert(movie3);
list.insert(movie);
list.erase(0);
Movie movie1("A", 2010, "PG", 1);
Movie movie2("B", 2011, "PG-13", 5);
Movie movie3("C", 2012, "PG", 4);
Movie movie4("D", 2013, "R", 3);
DoublyLinkedList< Movie> list;
list.insert(movie1);
list.insert(movie2);
list.insert(movie3);
list.insert(movie4);
list.sort();
Movie moviel("A", 2010, "PG", 1);
Movie movie2("B", 2011, "PG-13", 5);
Movie movie3("C", 2012, "PG", 4);
Movie movie4("D", 2013, "R", 3);
DoublyLinkedList< Movie> list;
list.insert(movie1);
list.insert(movie2);
list.insert(movie3);
list.insert(movie);
list.getHead();
Movie movie1("A", 2010, "PG", 1);
Movie movie2("B", 2011, "PG-13", 5);
Movie movie3("C", 2012, "PG", 4);
Movie movie4("D", 2013, "R", 3);
DoublyLinkedList< Movie> list;
list.insert(moviel);
list.insert(movie2);
list.insert(movie);
list.insert(movie4);
list.getTail();
Movie moviel("A", 2010, "PG", 1);
Movie movie2("B", 2011, "PG-13", 5);
Movie movie3("C", 2012, "PG", 4);
Movie movie4("D", 2013, "R", 3);
DoublyLinkedList< Movie> list;
list.insert(movie1);
list.insert(movie2);
list.insert(movie3);
list.insert(movie4);
list[0];