Starting from:

$30

CS0 Project 1: Sets Solved

Starting point ¶
Download and extract these materials. Contained are:

Driver.java, the provided driver program.
Movie.java, the things that will be held by a MovieShelf
SetFullException.java, an exception type
SetInterface.java and MovieShelfInterface.java, interfaces which you will implement in…
Set.java and MovieShelf.java. These are the files you will modify.
Do not modify anything other than Set.java and MovieShelf.java. We will be testing these with unmodified versions of the other files.

See the grading rubric further down to see the breakdown of the points.

Set  
You will implement the Set class. It implements SetInterface. Read the doc comments for each method in SetInterface carefully. In addition to the interface methods, you will also need to make some constructors, as detailed below.

Details of your Set implementation ¶
It will store its data in an array.
It will be dynamic capacity (like we talked about in Lecture 3).
The Set(int) constructor will initialize the array to the given capacity.It will check for an illegal capacity, and throw IllegalArgumentException in that case.
The Set() constructor will initialize the array to a reasonable default capacity.Reusing methods/constructors is a great habit! See section D.10 of Carrano (page 877 in the 4th edition) for details.
The Set(E[]) constructor will initialize the set to contain the items in the array.You will not make this array into the set’s backing array. That violates encapsulation.
The array may contain duplicates and nulls. You should ignore these instead of throwing an exception.
Do not duplicate your effort. This is essentially just adding all the items in the array to the set.
Although you are given SetFullException, your add method will never actually throw it.Since your implementation will dynamically resize its capacity, it can never be “full.”

MovieShelf 
You will implement the MovieShelf class. It implements MovieShelfInterface. Again, read the doc comments in that file carefully.

You are writing code that uses your own code. We call this “eating our own dogfood”. It’s kind of a gross term, but hey.

MovieShelf is a client of your Set. That is, it will have an instance of Set and use it to hold its data. This means you are creating this class via composition.

Details of your MovieShelf implementation ¶
It will store its data in a Set<Movie.
The MovieShelf() constructor will initialize that Set to be empty.
The MovieShelf(Movie[]) constructor will initialize that Set with that array of Movies.
A note on printAll(): you can use Set.toArray() to get the movies to print, but it is an array of Object. You will have to cast each item to a Movie to access its movie-specific getters.

More products