copyright Steve J. Hodges   http://steveh.net/cs19/cs19-hw03.html

CS19 Fall 2014

Assignment 3 (Integer Sets)

Directory Name

19-3

Resulting Executable

p3

Files

IntSet.cpp, IntSet.h, main.cpp, Makefile

Class Definition and Main

intset-stub.cpp


Program Description

Create a class, named IntSet, that implements a set that will store integer values in the range of 0 through 1000, inclusive. (Use a static const for this upper bound, so that the value can be modified, and your program re-compiled, to work with an alternate value.) If you don't remember the basics of sets and set operations, you may find the set entry at Wikipedia helpful. The required member functions are described below—do not modify them without consulting with me first.

You must use the code from the provided class definition and main function. Do not modify the provided code, except where indicated or to add comments, without consulting me. Don't forget to add all the proper array and object error checking. If you modify the main function or testing purposes while you are developing your program, return it to the provided code before you submit your assignment.

Your constructor must allow between zero and five elements to be inserted into the set initally.

Your member functions insertElement and deleteElement should work by adding (or deleting) the specified element to the set.

The toString member function should return a string containing standard set notation (comma seperated list.)

example sets:
{1, 2, 4, 6, 34, 58}
{1}
{}

The member function equals should have an integer set as its parameter and return type bool. It should determine if two sets have exactly the same members.

The intersection and union functions should be called intersectionOf and unionOf. Both should take two integer sets as their parameters and perform the requested operation by modifying the contents of the object on which it was invoked.

// s1 becomes the union of s2 and s3
s1.unionOf(s2,s3);

The member function hasElement should have return type bool and determine if the parameter is an element of the set. (Illegal element values should also return false.)

See starter file (intset-stub.cpp) for the required class definition and main function.

What to turn in

For this assignment, you will be creating a project with several files. All of your project files, including your makefile, should be placed in a directory named 19-3 inside your home directory on Pengo. This directory should not contain any files not part of your project, and it should not contain any subdirectories. I will collect all of the files from this directory.