Question
Your submission should consist of two (2) files: first-name_last-name_IntegerSet.h (class specification file) This file should declare all of the member variables and the prototypes for
Your submission should consist of two (2) files: first-name_last-name_IntegerSet.h (class specification file) This file should declare all of the member variables and the prototypes for constructors and functions. None of the constructors/functions should be implemented in this file.
first-name_last-name_IntegerSet.cpp (class implementation file) This file should contain the implementation for all of the constructors and functions.
For this programming assignment you will be creating a class named IntegerSet for which each object can hold integers in the range 0 through 100. Represent the set internally as a vector of bool values. Elementa[i] is true if integer i is in the set. Element a[j] is false if integer j is not in the set. The default constructor initializes a set to the so-called empty set, i.e., a set for which all elements contain false.
a. Provide member functions for the common set operations. For example, provide a unionOfSets member function that creates a third set that is the set-theoretic union of two existing sets (i.e., an element of the result is set to true if that element is true in either or both of the existing sets, and an element of the result is set to false if that element is false in each of the existing sets).
b. Provide an intersectionOfSets member function which creates a third set which is the set-theoretic intersection of two existing sets (i.e., an element of the result is set to false if that element is false in either or both of the existing sets, and an element of the result is set to true if that element is true in each of the existing sets).
c. Provide an insertElement member function that places a new integer k in to a set by setting a[k] to true. Provide a deleteElement member function that deletes integer m by setting a[m] to false.
d. Provide a printSet member function that prints a set as a list of numbers separated by spaces. Print only those elements that are present in the set (i.e., their position in the vector has a value of true). Print -- for an empty set.
e. Provide an isEqualTo member function that determines whether two sets are equal.
f. Provide an additional constructor that receives an array of integers and the size of that
array and uses the array to initialize a set object.
g. Provide the inputSet member function and the second constructor that are used in the application program as well.
The valid range of number is 0 100; any number outside of this range is considered invalid. The number -1 is treated asspecial case: it is used by the user to signal that they are done entering elements for the set.
Also, remember one of the member variables in the IntegerSet class is a vector of bools. Suppose this vector is named set with the following sample values:
set[0] = true (this means the number 0 is in the set) set[1] = false (this means the number 1 is NOT in the set) set[2] = false (this means the number 2 is NOT in the set) set[100] = true (this means the number 100 is in the set)
As another example, suppose the set consists of the values {0, 50, 100}. Then:
set[0] = true set[50] = true set[100] = true
And all other indexes in set would store false.
Finally, it is also possible for a set to be empty. An empty set is a set in which all indexes are set to false:
set[0] = false set[1] = false set[100] = false
An empty set is a set in which NONE of the numbers 0 100 occur in the set. In mathematics an empty set is represented as {}. In the program {--} will be printed out to represent an empty set.
The size of the vector is 101, with indexes 0 100. For each index, the Boolean valued stored (true or false) indicates whether that number is in the set or not.
Make sure to thoroughly test your program. You should get the same exact output as shown in the screenshots below for all six sample runs
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started