Implement sets represented by characteristic vectors using a C++ class. Keep all class members that are not accessed "from the outside" private. You must have at least 1 private class member. In your main class create 3 instances of your set named R, S and T, which initially do not contain any elements. The universal set for your set will correspond to the different values of the same suit in a deck of cards, i.e. there are 13 different values. You must use arrays or vectors for your implementation. it is ok to use if else statements to determine which set is referred to, or use of maps from the STL.
Once the program is started, it will print out the promt "sets> " (> is followed by a whitespace):
./a.out
sets>
You will implement the commands "assign", "clear", "union", intersection", "difference", "print" and "quit":
Assign takes 1 argument indicating the set name followed by 13 boolean values (represented by 0 or 1) separated by white spaces. Fill the set referenced with the corresponding values. If a set already had different values, simply override them. Then repeat the prompt.
sets> assign R 0 1 0 1 1 1 0 0 1 0 1 0 0
sets> assign S 1 0 0 0 0 0 1 0 1 0 1 1 1
sets> assign T 1 1 1 1 0 0 0 0 1 0 1 1 0
sets>
Clear takes a single argument indicating the set name. Remove all elements of the set. Then repeat the prompt.
sets> clear S
sets>
Union takes two arguments indicating the set names. Create the set union of the two sets without modifying the original sets. Print out the result separating the individual elements via hyphens. Then repeat the prompt.
sets> union R S
1-‐1-‐0-‐1-‐1-‐1-‐1-‐0-‐1-‐0-‐1-‐1-‐1
sets> union R T
1-‐1-‐1-‐1-‐1-‐1-‐0-‐0-‐1-‐0-‐1-‐1-‐0
sets> union S T
1-‐1-‐1-‐1-‐0-‐0-‐1-‐0-‐1-‐0-‐1-‐1-‐1
sets>
Intersection takes two arguments indicating the set names. Create the set intersection of the two sets without modifying the original sets. Print out the result separating the individual elements via hyphens. Then repeat the prompt.
sets> intersection S R
0-‐0-‐0-‐0-‐0-‐0-‐0-‐0-‐1-‐0-‐1-‐0-‐0
sets> intersection T S
1-‐0-‐0-‐0-‐0-‐0-‐0-‐0-‐1-‐0-‐1-‐1-‐0
sets> intersection R T
0-‐1-‐0-‐1-‐0-‐0-‐0-‐0-‐1-‐0-‐1-‐0-‐0
sets>
Difference takes two arguments indicating the set names. Create the set difference of the two sets without modifying the original sets. Print out the result separating the individual elements via hyphens. Then repeat the prompt.
sets> difference R S
0-‐1-‐0-‐1-‐1-‐1-‐0-‐0-‐0-‐0-‐0-‐0-‐0sets> difference S R
1-‐0-‐0-‐0-‐0-‐0-‐1-‐0-‐0-‐0-‐0-‐1-‐1
sets> difference T R
1-‐0-‐1-‐0-‐0-‐0-‐0-‐0-‐0-‐0-‐0-‐1-‐0
sets>
Print takes a single argument indicating the set name. Print out all the elements of the set indicated separated by hyphens. Then repeat the prompt.
sets> print S
1-‐0-‐0-‐0-‐0-‐0-‐1-‐0-‐1-‐0-‐1-‐1-‐1
sets> print R
0-‐1-‐0-‐1-‐1-‐1-‐0-‐0-‐1-‐0-‐1-‐0-‐0
sets> print T
1-‐1-‐1-‐1-‐0-‐0-‐0-‐0-‐1-‐0-‐1-‐1-‐0sets>
Exit the program
sets> quit
If the command received from the user input is not supported, print out an error message starting with "Error!".