A movie consists of a title, rating and running time (in minutes). You will complete a class that maintains a collection of movies and performs various operations on the collection as described below.
Click HERE to download a project named MovieDatabase that you will complete for this lab. Move this to your workspace and open it in Eclipse. This project contains the following classes:
Once you are done writing this method, compile and run the CountTester class to check your answer. You should get the following final answer:
The number of films with rating G: 3 The number of films with rating PG: 2 The number of films with rating PG-13: 4 The number of films with rating R: 1 The number of films with rating NC-17: 0
In this version, there is private helper method doubleLength that doubles the size of the array. You should call this method only if the array is currently full when you try to insert a new movie. Thus, you can always add a new movie, and you don't need a warning that the array is full.
Once you are done writing this method, compile and run the InsertTester class to check your answer. You should get the following final answer (make sure that the array size is correct too):
Size of movieArray: 16 Number of movies in collection: 10 movieArray[0]: Borat R 104min. movieArray[1]: Casino Royale PG-13 132min. movieArray[2]: Ice Age: The Meltdown G 104min. movieArray[3]: Happy Feet G 98min. movieArray[4]: Superman Returns PG 120min. movieArray[5]: The Da Vinci Code PG-13 145min. movieArray[6]: X-Men: The Last Stand PG-13 128min. movieArray[7]: Cars G 115min. movieArray[8]: Night at the Museum PG 104min. movieArray[9]: Pirates of the Carribbean II PG-13 132min.
Once you are done writing this method, compile and run the RemoveAllTester class to check your answer.
HINT: Examine each movie one at a time using a loop. If the movie matches the criteria, immediately shift all other movies over one position to remove that movie using another loop. (So you will have nested loops.) Be careful: if you shift movies, the next movie to check is in the same position as the movie you just removed!
At the end of lab, create a zip file of your program and submit it to the handin server: http://handin.intro.cs.cmu.edu/v1