class Set { /* * This exception is thrown by various methods * of the Set class. * * The constructor takes a string that describes the specific * situation */ public class SetException extends Exception { public SetException (String s) { super (s); } } /* * Declare any instance variables here */ /* * This is the default constructor. * It just creates an empty set. * Basically, it creates an empty linked list. */ public Set() { /* * Your code here */ } /* * This is a copy constructor. It creates a new set from * an old set */ public Set (Set original) throws SetException { /* * Your code here */ } /* * Returns the items in the set as a string */ public String toString() { /* * Your code here */ } /* * Returns true if the item is in the set and false * otherwise */ public boolean member(Object item) { /* * Your code here */ } /* * This method should add an item to the set. It should throw * an exception if the item is already in the set. * * Specifically, you should define a SetException and throw * this exception. When you create a new instance of this * exception, you should set its value to "Item already in set." */ public void addItem (Object item) throws SetException { /* * Your code here */ } /* * This method should add all of the items from the newItems set * into the original set. It should throw an exception * upon discovering that any requested item is already in the set. * * Specifically, you should define a SetException and throw * this exception. When you create a new instance of this * exception, you should set its value to "Item already in set." */ public void addItems (Set newItems) throws SetException { /* * Your code here */ } /* * This method should remove an item from the set. It should throw * an exception if the item is not in the set. * * Specifically, you should define a SetException and throw * this exception. When you create a new instance of this * exception, you should set its value to "Item not already in set." */ public void removeItem (Object item) throws SetException { /* * Your code here */ } /* * This method should remove all of the items in the "items" Set * from the current set. It should throw an exception * upon discovering that any of the specified items is not in the * target set. * * Specifically, you should define a SetException and throw * this exception. When you create a new instance of this * exception, you should set its value to "Item not already in set." */ public void removeItems (Set items) throws SetException { /* * Your code here */ } /* * This returns a new set that contains every element in * the original set and the set provided by the user */ public Set union (Set in_set) throws SetException { /* * Your code here */ } /* * This returns a new set that contains only those elements * in the original set and the set provided by the user */ public Set intersection (Set in_set) throws SetException { /* * Your code here */ } /* * This returns a new set that contains only those elements * in the original set or the set provided by the user, but * not both. */ public Set xor (Set in_set) throws SetException { /* * Your code here */ } /* * This returns true if the specified set is a proper subset of the target * set and false otherwise. */ public boolean subset (Set subset) throws SetException { /* * Your code here */ } /* * This should be a test driver. * It should perform no user or file I/O whatsoever. * Instead, it should be a static test set that convinces * us that your Set class works. It should test all of the * special cases, all of the boundary cases, and the common * cases. */ public static void main (String []argv) throws SetException { /* * Your code here */ } }