Write a class for a set of integers - there are no duplicates in the Set
A number can be in there only once
class intSet
{ final int MAX = 20;
private int [] ar = new int[20];
private int ct;
public intSet(); // creates empty set
public void clear(); clears set
public void add(int n); //adds n if it is not in set already
public boolean contains(int n); // returns true if n is in set
public int size(); // returns number of elements in the set
public int itemAt(int x); // returns item in spot x
public void print(); // prints set of integers
public void remove(int n); // removes n from set if it is in there
public boolean equals(intSet is); //returns true if sets are equal
public boolean subset(intSet is); //returns true if is is suset of this set
public intSet union(intSet is); // returns union of 2 sets - all elements
public intSet interesection(intSet is); // returns intersection of 2 sets - what they have in common
}
Write a driver program that works with at least 2 Integer Sets.
Make sure you test Union, Intersections and subset.