Here is a problem in C++:

## Problem:
(40% of DD1; 20% of DD2) For this question: use C++20 imports. Compile the system headers with g++20h and
compile your files with g++20.
In this question, you will implement a class that represents a mathematical set for integers using std::vector. The
class definition and its associated method and function signatures have been given to you in the file IntSet.cc in
your repository.
You have also been given a test harness in a4q1.cc as the main function. Do not change it. Make sure you read and
understand this code, as you will need to know what it does in order to structure your test suite. It isn’t very robust and
does no error-checking. You are allowed to assume that the commands it receives are valid, so do not write test cases
for it!
Implement the described IntSet methods and functions. Your implementation must satisfy the following require-
ments:
• A set cannot contain duplicate items. Attempting to add an item already in the set does not change the set nor does
it produce an error (see add and operator&).
• Set intersection (operator&) returns a new set containing only the elements that are in both sets.
• Set union (operator|) returns a new set containing all of the elements from both sets, without any duplicates.
• Two sets A and B are equal (operator==) if and only if no element of one is not an element of the other. More
precisely: (∄xs.t.x ∈A ∧x /∈B) ∧(∄xs.t.x ∈B ∧x /∈A).
• i1.isSubset( const IntSet & i2 ) returns true if and only if every element in i2 is an element of
the set i1: otherwise it returns false.
• i.contains( int e ) returns true if e is an element of the set i: otherwise it returns false.
• After i.remove( int e ) is called, e must not be in the set i.
• The input operator (operator>>) adds the read-in integers to the set until a non-integer value is read. The first
non-integer character is thrown away.
• The output operator (operator<<) first prints a left parenthesis ’(’, then each integer in added order, delim-
ited by a space, and ends with a right parenthesis ’)’. For example the set containing 3, 5, and 2 is printed as
( 3 5 2 ). An empty set is printed as ( ).
(a) Due on Due Date 1: Design a test suite for this program. Submit a file called a4q1a.zip that contains the test
suite you designed, called suiteq1.txt, and all of the .in and .out files.

## Interface File
export module intset;

import <iostream>;
import <vector>;

export class IntSet {
    std::vector<int> data;

  public:

    class Iterator {     
      public:
        int operator*() const {
          return data->at(pos);
        }
        Iterator& operator++() {
          pos++;
          return *this;
        }
        bool operator!=(const Iterator & it) const {
          return pos != it.pos;
        }
        friend class IntSet;
      private:
        Iterator(const std::vector<int> *data, size_t pos): data{data}, pos{pos} {}
        const std::vector<int> *data;
        size_t pos;
    };

    IntSet* operator|( const IntSet & i ) const;  // Set union.
    IntSet* operator&( const IntSet & i ) const;  // Set intersection.
    bool operator==( const IntSet & i ) const;    // Set equality.
    bool isSubset( const IntSet & i ) const;      // True if i is a subset of "this".
    bool contains( int e ) const;                 // True if "this" contains element e.

    void add( int e );                            // Adds element e to "this".
    void remove( int e );                         // Removes element e from "this".

    Iterator begin() const;
    Iterator end() const;
};

// Output operator for IntSet.
export std::ostream& operator<<( std::ostream & out, const IntSet & is );

// Input operator for IntSet. Continuously read int values from in and add to the passed IntSet.
// Function stops when input contains a non-int value. Discards the first non-int character.
export std::istream& operator>>( std::istream & in, IntSet & is );

## Implementation file:
module intset;

IntSet* IntSet::operator|(const IntSet &i) const {
    IntSet *newSet = new IntSet;

    for (const auto &n : data) {
        newSet->add(n);
    }

    for (const auto &n : i.data) {
        newSet->add(n); // Add checks for duplicates
    }

    return newSet;
}

IntSet* IntSet::operator&(const IntSet &i) const {
    IntSet *newSet = new IntSet;

    for (const auto &n : data) {
        if (i.contains(n)) {
            newSet->add(n);
        }
    }

    return newSet;
}

bool IntSet::operator==(const IntSet &i) const {
    return isSubset(i) && i.isSubset(*this);
}

bool IntSet::isSubset(const IntSet &i) const {
    for (const auto &n : i.data) {
        if (!contains(n)) return false;
    }

    return true;
}

bool IntSet::contains(int e) const {
    for (const auto &n : data) {
        if (n == e) return true;
    }
    return false;
}

void IntSet::add(int e) {
    if (!contains(e)) data.emplace_back(e);
}

void IntSet::remove(int e) {
    for (auto it = data.begin(); it != data.end(); ++it) {
        if (*it == e) {
            it = data.erase(it); // This is not necessary to do since no duplicates, but for best practice's sake
            break; // Each element in the set is unique
        }
        else {
            ++it;
        }
    }
}

IntSet::Iterator IntSet::begin() const {
    return IntSet::Iterator{ &data, 0 };
}

IntSet::Iterator IntSet::end() const {
    return IntSet::Iterator{ &data, data.size() };
}

// Output operator for IntSet.
std::ostream& operator<<(std::ostream &out, const IntSet &is) {
    out << "( ";
    for (const auto &n : is) {
        out << n << " ";
    }

    return out << ")";
}

// Input operator for IntSet. Continuously read int values from in and add to the passed IntSet.
// Function stops when input contains a non-int value. Discards the first non-int character.
std::istream& operator>>(std::istream &in, IntSet &is) {
    int data;
    while (in >> data) {
        is.add(data);
    }

    in.clear();
    in.ignore();

    return in;
}

## Test Harness
import <iostream>;
import <sstream>;
import intset;

using namespace std;

const int MAX_INT_SETS = 5;

// Test harness for IntSet functions. You may assume that all commands entered are valid.
// Valid commands: n <ind>,  p <ind>, & <ind1> <ind2>,
//                 | <ind1> <ind2>, = <ind1> <ind2>,
//                 s <ind1> <ind2>, c <ind1> <elem>,
//                 a <ind1> <elem>, r <ind1> <elem>,
//                 q/EOF
// Silently ignores invalid commands. Doesn't check that 0 <= index < MAX_INT_SETS.
// Do not test invalid commands!

int main() { 
    IntSet *sets[MAX_INT_SETS]{nullptr}, *tmpSet{nullptr};
    char c;

    while ( cin >> c ) {
        int lhs, rhs;

        if ( c == 'q' ) break;

        switch(c) {
          case 'n':
            // Create new IntSet at index lhs after destroying the old.
            // Read in integers to add to it until hitting non-int using operator>>.
            cin >> lhs;
            delete sets[lhs];
            sets[lhs] = new IntSet;
            cin >> *sets[lhs];
            break;

          case 'p':
            // Print IntSet at lhs.
            cin >> lhs;
            cout << *sets[lhs] << endl;
            break;

          case '&':
            // Print intersection of lhs and rhs.
            cin >> lhs >> rhs; // reads in two indices
            delete tmpSet;
            tmpSet = (*sets[lhs] & *sets[rhs]);
            cout << *tmpSet << endl;
            break;

          case '|':
            // Print union of lhs and rhs.
            cin >> lhs >> rhs;
            delete tmpSet;
            tmpSet = (*sets[lhs] | *sets[rhs]);
            cout << *tmpSet << endl;
            break;

          case '=':
            // Print true if lhs == rhs, false otherwise.
            cin >> lhs >> rhs;
            cout << boolalpha << (*sets[lhs] == *sets[rhs]) << endl;
            break;

          case 's':
            // Print true if rhs is subset of lhs, false otherwise.
            cin >> lhs >> rhs;
            cout << boolalpha << sets[lhs]->isSubset( *sets[rhs] ) << endl;
            break;

          case 'c':
            // Print true if lhs contains element rhs, false otherwise.
            cin >> lhs >> rhs;
            cout << boolalpha << sets[lhs]->contains( rhs ) << endl;
            break;

          case 'a':
            // Add elem rhs to set lhs
            cin >> lhs >> rhs;
            sets[lhs]->add( rhs );
            break;

          case 'r':
            // Remove elem rhs from set lhs
            cin >> lhs >> rhs;
            sets[lhs]->remove( rhs );
            break;
            
        } // switch
    } // while

    for ( auto s : sets ) delete s;
    delete tmpSet;
} // main


## Instructions
Create 10-20 tests (or more if necessary) that properly test the functionality of this program including any and all edge cases. State each case/testing functionality. I will also present you with a sample test below.

## Sample Test
n 0
x
n 1
7 1 2 x
p 0
p 1
= 0 1