Question: Homework 4 - Square Set Introduction In this assignment you will practice implementing interfaces, using generics, using exceptions, and implementing simple data structures. Problem Description

Homework 4 - Square Set Introduction In this assignment you will practice implementing interfaces, using generics, using exceptions, and implementing simple data structures. Problem Description You want a convenient collection class for Squares. Solution Description Write a SquareSet class that implements Set. Implement all required methods as well as the add method. For all other optional methods follow the instructions in the Set API documentation (what happens when a user calls an optional method that has not been implemented?). Implement the two constructors specified in the Collections interface documentation. If an invalid square is added, throw the InvalidSquareException you created in the previous homework. You may need to modify your InvalidSquareException class. If a null is added, throw a NullPointerException. Use an array as your backing store. Set implements Iterable. So youll also need to write a class that implements Iterator, an instance of which you should return from SquareSets iterator method. Your Iterator class should be an inner class. For each class include Javadoc comments as described in the CS 1331 style guide. Grading 5 points: no-arg contsructor creates an instance of SquareSet 5 points: SquareSet(Collection) contsructor creates an instance of SquareSet with no duplicates or nulls 5 points: add method adds a valid Square not already in the set 5 points: add method throws exceptoin for attempt to add and invalid Square 5 points: add method does not add a valid Square already in the set 10 points: contains 5 points: containsAll 10 points: equals 10 points: hashCode 10 points: isEmpty 10 points: iterator 5 points: size 5 points: toArray 10 points: toArray(T[] a) Bonus: 10 points: addAll adds all Squares in argument if all squares are valid 10 points: addAll throws InvalidSquareExceptoin and adds no Squares from argument if any Square in argument is invalid 10 points: addAll adds Squares from arguemnt that are not already in set but not any Squares that are already in the set 10 points: remove removes argument from set Checkstyle deduction will be capped at 50 points for this homework.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!