Question: Set Class Use the files: ArrayBag.h and ArrayBag.cpp to implement the Set class for integers as described in Chapter 1, Exercises 6 and 8 at
Set Class
Use the files: ArrayBag.h
and ArrayBag.cpp
to implement the "Set" class for integers as described in Chapter 1, Exercises 6 and 8 at page 28. ArrayBag, makes an array ADT with many of the functions of a STL vector. Please use this NOT a vector. To verify your set class, write a main function that takes two sets of integers from an input file setInput.txt, and store them into separate sets, and apply following two operations.
First, combine the two into one set by overloading the + (union) operator, and print out the union set. The + operator must remove all duplicates and store one copy of any item. You also need to implement a subtraction operator (difference) where (A-B means removing all elements of B from A) and print out the result. So the main function takes two sets of integers and print the result of + and - operation.
A sample setInput.txt
may look like this. Note that we assume the input file includes only two sets of integer numbers, each number is separated by white spaces and sets are separated by a newline character. 3 4 5 7 5 16 7 12 11 12 3 9 9 8 1 12 15 4 3 6 1 12 3 12 7 8 19 9 11 12 8 5 -4 -100
Validate that all inputs are integers. Anything else should be rejected with an error message. See validateInput.cpp
for an idea of how to validate input. After validating, instead of putting them into a vector, you might add them to a "Set" to meet this homework's requirement.
You should submit a single lastnameHW2.zip containing: ArrayBag.h, ArrayBag.cpp, main.cpp, SetFunctions.h, SetFunctions.cpp, makefile, and Readme.txt and setInput.txt.
Can someone help me on this problem please?
will appreciate!!!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
