Reference no: EM1369844
1. Design and implement a generic Set class with attributes you find necessary and with the following methods. Set class has nonduplicate elements.
size : return the number of items in the set as an integer
clear : removes all of the items
add : adds the item passed as a parameter to the set if it is not already in the set. Returns the result of addition as a boolean value
contains : checks the Set for the item passed as the parameter, returns true if the item is in the set, false otherwise
isEmpty : returns true if there are no items in the set, false otherwise
remove : removes the item passed as the parameter if it is in the set and returns the result of removal as a boolean value
toArray : Returns the items in the Set as an array of the type of items in the set (e.g., if the Set object stores Strings, the returned array will be of type String)
toString : Displays all the items in the set
subSets : Returns all possible subsets of the Set excluding empty set, as a Set array of the same type.
join : Implements join operation on the current Set and the Set object of the same type passed as parameter and returns a NEW Set object that stores the result of the join operation.
intersect : Implements intersection operation on the current Set and the Set objects of the same type passed as parameter and returns a NEW Set object that stores the result of the intersection operation.
2. Demonstrate the capabilities of your classes. Be sure to provide at least two sets and use all of the methods in your class. You are free to use a text based or a graphical user interface.