Using java: Your task is to implement a class, IntegerSet, that contains only integers, given the specification below. public class IntegerSet { // Hint: probably best to use an array list. You will need to do a little research private List set = new ArrayList(); // Default Constructor public IntegerSet() { } // Clears the internal representation of the set public void clear() {…}; // Returns the length of the set public int length() {…}; // returns the length /* * Returns true if the 2 sets are equal, false otherwise; * Two sets are equal if they contain all of the same values in ANY order. */ public boolean equals(IntegerSet b) {…}; // Returns true if the set contains the value, otherwise false public boolean contains(int value) {…}; // Returns the largest item in the set; Throws a IntegerSetException if the set is empty public int largest() {…}; // Returns the smallest item in the set; Throws a IntegerSetException if the set is empty public int smallest() IntegerSetException {…}; // Adds an item to the set or does nothing it already there public void add(int item) {…}; // adds item to the set or does nothing if it is in set // Removes an item from the set or does nothing if not there public void remove(int item) {…}; // Set union public void union(IntegerSet intSetb) {…}; // Set intersection public void intersect(IntegerSet intSetb) {…}; // Set difference, i.e., s1 –s2 public void diff(IntegerSet intSetb); // set difference, i.e. s1 - s2 // Returns true if the set is empty, false otherwise boolean isEmpty(); // Return String representation of your set public String toString() {…}; // return String representation of your set } Below is a sample of how your driver should look. Your driver contains your main method and its primary function is to test your IntegerSet class. Every method in IntegerSet should be sufficiently tested and your output easy to read. Below is a small example of the granularity of how your output should look. Each operation on a method should show the contents of your IntegerSet before and after each operation. Part of your grade on this assignment is how expressive your output is. … IntegerSet set1 = new IntegerSet(); set1.add(1); set1.add(2); set1.add(3); System.out.println(“Value of Set1 is:” + set1.toString()); System.out.println(“Smallest value in Set1 is:” + set1.smallest()); System.out.println(“Largest value in Set1 is:” + set1.largest()); IntegerSet set2 = new IntegerSet(); set2.add(4); set2.add(5); System.out.println(“Union of Set1 and Set2”); System.out.println(“Value of Set1 is:” + set1.toString()); System.out.println(“Value of Set2 is:” + set2.toString()); set1.union(set2); // union of set1 and set2 System.out.println(“Result of union of Set1 and Set2”); set1.toString(); // result of union of set1 and set2 The above format is just a template to use. At the end of the day your output should be an indicator that your program works for ALL methods in IntegerSet. You should create Driver.java that contains all of your test code.
Using java:
Your task is to implement a class, IntegerSet, that contains only integers, given the specification below.
public class IntegerSet {
// Hint: probably best to use an array list. You will need to do a little research
private List<Integer> set = new ArrayList<Integer>();
// Default Constructor
public IntegerSet() {
}
// Clears the internal representation of the set
public void clear() {…};
// Returns the length of the set
public int length() {…}; // returns the length
/*
* Returns true if the 2 sets are equal, false otherwise;
* Two sets are equal if they contain all of the same values in ANY order.
*/
public boolean equals(IntegerSet b) {…};
// Returns true if the set contains the value, otherwise false
public boolean contains(int value) {…};
// Returns the largest item in the set; Throws a IntegerSetException if the set is empty
public int largest() {…};
// Returns the smallest item in the set; Throws a IntegerSetException if the set is empty
public int smallest() IntegerSetException {…};
// Adds an item to the set or does nothing it already there
public void add(int item) {…}; // adds item to the set or does nothing if it is in set
// Removes an item from the set or does nothing if not there
public void remove(int item) {…};
// Set union
public void union(IntegerSet intSetb) {…};
// Set intersection
public void intersect(IntegerSet intSetb) {…};
// Set difference, i.e., s1 –s2
public void diff(IntegerSet intSetb); // set difference, i.e. s1 - s2
// Returns true if the set is empty, false otherwise
boolean isEmpty();
// Return String representation of your set
public String toString() {…}; // return String representation of your set
}
Below is a sample of how your driver should look. Your driver contains your main method and its primary function is to test your IntegerSet class. Every method in IntegerSet should be sufficiently tested and your output easy to read. Below is a small example of the granularity of how your output should look. Each operation on a method should show the contents of your IntegerSet before and after each operation. Part of your grade on this assignment is how expressive your output is.
…
IntegerSet set1 = new IntegerSet();
set1.add(1);
set1.add(2);
set1.add(3);
System.out.println(“Value of Set1 is:” + set1.toString());
System.out.println(“Smallest value in Set1 is:” + set1.smallest());
System.out.println(“Largest value in Set1 is:” + set1.largest());
IntegerSet set2 = new IntegerSet();
set2.add(4);
set2.add(5);
System.out.println(“Union of Set1 and Set2”);
System.out.println(“Value of Set1 is:” + set1.toString());
System.out.println(“Value of Set2 is:” + set2.toString());
set1.union(set2); // union of set1 and set2
System.out.println(“Result of union of Set1 and Set2”);
set1.toString(); // result of union of set1 and set2
The above format is just a template to use. At the end of the day your output should be an indicator that your program works for ALL methods in IntegerSet. You should create Driver.java that contains all of your test code.
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 4 steps with 7 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)