Using Java
The given class SetInterface.java is :
public interface SetInterface {
  /**
  * Gets the current number of entries in thisset.
  *
  * @return The integer number of entries currentlyin the set.
  */
  public int getSize();
  /**
  * Sees whether this set is empty.
  *
  * @return True if the set is empty, or false ifnot.
  */
  public boolean isEmpty();
  /**
  * Adds a new entry to this set, avoidingduplicates.
  *
  * @param newEntry The object to be added as a newentry.
  * @return True if the addition is successful, orfalse if the item already is
  * in the set.
  */
  public boolean add(T newEntry);
  /**
  * Removes a specific entry from this set, ifpossible.
  *
  * @param anEntry The entry to be removed.
  * @return True if the removal was successful, orfalse if not.
  */
  public boolean remove(T anEntry);
  /**
  * Removes one unspecified entry from this set, ifpossible.
  *
  * @return Either the removed entry, if the removalwas successful, or null.
  */
  public T remove();
  /** Removes all entries from this set. */
  public void clear();
  /**
  * Tests whether this set contains a givenentry.
  *
  * @param anEntry The entry to locate.
  * @return true if the set contains anEntry, orfalse if not.
  */
  public boolean contains(T anEntry);
  /**
  * Returns true if one set is equivalent to another(contains the same
  * elements), and false otherwise.
  *
  * @param anotherSet another set
  * @return true if this set contains the sameelements as the other set, or
  * false if not.
  */
  public boolean isEquivalentTo(SetInterfaceanotherSet);
  /**
  * Returns true if all of the elements of this setare contained in the other
  * set, and false otherwise.
  *
  * @param anotherSet another set
  * @return true if all of the elements of this setare contained in the other
  * set, and false otherwise.
  */
  public boolean isSubsetOf(SetInterfaceanotherSet);
  /**
  * Computes the union of this set with a givenset
  *
  * @param anotherSet another set
  * @return the union of this set with anotherSet
  */
  public SetInterfaceunion(SetInterface anotherSet);
  /**
  * Computes the intersection of this set with agiven set
  *
  * @param anotherSet another set
  * @return the intersection of this set withanotherSet
  */
  public SetInterfaceintersection(SetInterface anotherSet);
  /**
  * Retrieves all entries that are in this set.
  *
  * @return A newly allocated array of all theentries in the set, where the size
  * of the array is equal to the number of entries inthe set.
  */
  public T[] toArray();
} // end SetInterface
1. (63 points) Create a class ResizableArraySet that implementsthe methods in SetInterface.java file that you have been provided(do not modify the given interface file). There should be just oneconstructor, with no parameters, that creates a Set containing noelements (but the underlying array should have an initial length of5). Methods should avoid unnecessary code duplication, usingprivate helper methods to reduce repeated code. â—‹ Double the sizeof the array when the array is full. â—‹ After removing an element,if the array is less than half full, then cut the size of the arrayin half. However, the size of the array should never be less than5. â—‹ Write a toString() method that returns a comma-separated listof the data in the set, surrounded by curly braces (such as \"{A, C,B}\"). (write early so you can test)
2. (See sample run at the end of this document) In a separateclass, Tester, create a void method named setTester() that has noparameters and: â—‹ (10 points) Creates an array consisting ofseveral strings, including some repeated strings, and then addsthem to one of your sets, displaying information about your set asit goes. Then, remove the elements you added, in the same orderthat you added them. The idea is that this will help you showyourself (and us) that all the methods in your Set class areworking. â—‹ (10 points) Creates another set and adds 20 randomintegers in the range 0 to 99. Each time a number is added, printthe number that was added, along with the contents of the set. Notethat if duplicates are added, then the set size after adding 20numbers would actually be less than 20. After adding the numbers tothe set, use a loop to remove all even numbers from the set,showing the number that was removed, and the resulting set. Onlyshow the removal if the number is actually in the set. Â
The final testing file:
import java.awt.Point;
public class BaselineTester {
  public static void main(String[] args) {
     testResizableArraySet();
     testNodeClass();
     testTester();
  }
 Â
  // Verifies that the proper methods and constructorexist in ResizableArraySet
  // If this tester contains compiler errors, itindicates a problem with your code.
  // Do not modify this tester. Instead, modify yourResizableArraySet code.
  public static void testResizableArraySet() {
    Â
     // Is it possible to createdifferent kinds of sets?
     SetInterface set1= new ResizableArraySet<>();
     SetInterface set2 =new ResizableArraySet<>();
     SetInterface set3= new ResizableArraySet<>();
    Â
     // Test the add and removemethods:
     boolean b = set1.add(\"cat\");
     b = set1.remove(\"cat\");
     String s = set1.remove();
     set1.clear();
     int i = set1.getSize();
    Â
     String[] arr =set1.toArray();
    Â
     SetInterface set4 =new ResizableArraySet<>();
     SetInterface set5 =new ResizableArraySet<>();
     SetInterface set6 =set4.union(set5);
     set6 =set4.intersection(set5);
    Â
     b = set6.contains(newPoint());
     b =set6.isEquivalentTo(set5);
     b = set6.isSubsetOf(set5);
     b = set6.isEmpty();    Â
  }
 Â
  // This makes sure that your Node class exists andhas package-level instance variables
  // named data and next, and a constructor that hasan int parameter.
  public static void testNodeClass() {
     Node n = new Node(5);
     int i = n.data;
     Node n2 = n.next;
  }
 Â
  // This makes sure that you have a class namedTester and that the class has static
  // methods with the proper names.
  public static void testTester() {
     Tester.setTester();
     Tester.nodeTester();    Â
  }
 Â
}