Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Implement the ADT Set ( in Java ) using array data structure as specified. The following additional operations are to be defined in the SetInterface:
Implement the ADT Set in Java using array data structure as specified.
The following additional operations are to be defined in the SetInterface:
equalsSetInterface rhs: returns true if both sets contain the same elements. AequalsB
unionSetInterface rhs: if A B C are sets, has the form C AunionB Union returns a set that
contains all the elements in set A and B but only lists duplicates once.
intersectSetInterface rhs: if A B C are sets, has the form C AintersectB intersect returns
a set of all objects that are members of both the sets A and B
SetInterface must extends Iterable.
toString: returns a string that indicates an object's state. An object's state is the data that is
currently stored in the object's fields. Format: abc
Remember from your CS that the empty set is a set, and the empty set is a subset of every set. If A B then CAintersectB is C
You must implement the generic ArraySet class.
Your generic SetInterface must be documented for Javadoc.
You must include a SetTest with a main to test your Set ADT. Remember that when you test
equals and intersection, test each method with at least the following five cases:
Case : A and B are equal but distinct sets, for example, A B
Case : A and B are such that they have different sizes, but one is a subset of the other, for example, A B
Case : A and B are nonempty and different in size but have common elements, for example, A B
Case : they are nonempty with nothing in common, for example, A B and
Case : one is nonempty and the other empty.
You need to make sure that you have thoroughly tested every method of your set class. For the test program, you must hardcode all the special cases. There will be NO input to this program.
There should be Java source and the report files:
SetInterface.java ArraySet.java SetTest.java
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