Starting from:
$30

$24

CompSci Assignment 4 Solved

Program Specification

You are to write a class called MovieCollection following the diagram below. You may use your Movie class you wrote in lab, but notice a few small changes have been made. A few methods have been removed, and a few have been added. Also the format it prints out in is slightly different as well.

Requirements

Your Movie objects are stored in an array in the MovieCollection class. For this assignment, you are only allowed to hold 10 movies at a time, even though in real life you may own many more. Another instance variable you have to manage is the movieCount variable. The movieCount variable is meant to tell how many movies you currently have, and where the next movie is to be added if it can. The movieCount variable may only increment or decrement by one when necessary. Also, no null elements are allowed between the start of the array to movieCount, ie no empty movie slots.

The movies do not need to be sorted. They are simply added to where movieCount is currently pointing or where specified by addMovieAt(int index). If you have 10 movies, it should not add any more movies unless you remove a movie.

In the assignment description I have added many comments above each method to give further descriptions.

I have provided Junit testing for most methods and a simple driver you may use to test your code.
Below is a sample out.

One last comment about the Movie class from lab, it may not have been as obvious from seeing the code below, but toString() converts the minutes to hours and minutes. For example, 125 converts to 2hrs 5min. You may add a private helper method to do the conversion if you wish.


Grad Students

You will add more test cases to the removeMovieAt method. I have not done extensive testing on this method, so you are responsible for providing further testing on it. Think of what values could make a test fail and test for false results. Or simply add a random set of method calls to shift things around and ensure removeMovieAt returns the correct values.


Driver Output

Total movies: 7
All of my movies:

Movie 1: Crazy Rich Asians
Movie 2: Oceans 8

Movie 3: The Happytime Murders

Movie 4: Mission Impossible: Fallout
Movie 5: Slender man

Movie 6: The Big Sick
Movie 7: Mile 22

Can I add the The Big Sick again?

No, it is already in your collection.

Is A Quiet Place in my collection?

It is not there.

Time to remove Oceans 8.
Oceans 8 was removed.

Can I remove Oceans 8 again?
Nope, it was already removed.

All of my movies:

Movie 1: Crazy Rich Asians
Movie 2: The Happytime Murders

Movie 3: Mission Impossible: Fallout

Movie 4: Slender man
Movie 5: The Big Sick

Movie 6: Mile 22

Time to add Jurassic World: Fallen Kingdom at the end of collection.
Wonder Woman at the beginning.

Goodfellas at slot 8.

Finally A Quiet Place at the end.

All of my movies:
Movie 1: Wonder Woman

Movie 2: Crazy Rich Asians
Movie 3: The Happytime Murders

Movie 4: Mission Impossible: Fallout

Movie 5: Slender man
Movie 6: The Big Sick

Movie 7: Mile 22
Movie 8: Goodfellas

Movie 9: Jurassic World: Fallen Kingdom

Movie 10: A Quiet Place

Movies to avoid:
Movie 1:
Name: The Happytime Murders
Length : 1hrs 31min

Tomato Rating : Rotten

Movie 2:

Name: Slender man
Length : 1hrs 33min

Tomato Rating : Rotten

Movie 3:

Name: Mile 22
Length : 1hrs 30min

Tomato Rating : Rotten

Movie 4:
Name: Jurassic World: Fallen Kingdom

Length : 2hrs 9min

Tomato Rating : Rotten

Movies to watch:
Movie 1:
Name: Wonder Woman
Length : 2hrs 21min

Tomato Rating : Fresh

Movie 2:

Name: Crazy Rich Asians
Length : 2hrs 0min

Tomato Rating : Fresh

Movie 3:
Name: Mission Impossible: Fallout

Length : 2hrs 27min

Tomato Rating : Fresh

Movie 4:
Name: The Big Sick

Length : 1hrs 59min
Tomato Rating : Fresh

Movie 5:
Name: Goodfellas

Length : 2hrs 26min
Tomato Rating : Fresh

Movie 6:
Name: A Quiet Place

Length : 1hrs 30min
Tomato Rating : Fresh


The Best Movie is?

The Big Sick

Time to remove the best movie.
Success, it was removed correctly.

All of my movies:

Movie 1: Wonder Woman

Movie 2: Crazy Rich Asians
Movie 3: The Happytime Murders

Movie 4: Mission Impossible: Fallout
Movie 5: Slender man

Movie 6: Mile 22
Movie 7: Goodfellas

Movie 8: Jurassic World: Fallen Kingdom

Movie 9: A Quiet Place


Can I remove a movie at impossible indexes?

Nope, negative indexes do not work.
Nope, index is too large.

More products