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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started