Homework 4: UintSet Solution

$35.00 $29.05

You'll get a: . zip file solution, download link after Payment


Educational Objectives. After successfully completing this = assignment,=20 the student should be able to accomplish the following:

  • Design a class based on non-language-specific specifications=20

  • Implement a class of your own design=20

  • Implement constructors, copy constructor, destructor, and = assignment=20 operator for a class that has resource allocation requirements=20

  • Global operators for a class=20

  • Correctly separate class definition and implementation using files =

  • Create executables of class client programs using makefiles and = the Make=20 utility=20

  • Test a class using specs and an existing test platform=20

  • Use fsu::BitVector in designing set classes

Operational Objectives: Define and implement the = class=20 UIntSet and deliver the code in two files uintset.h = and=20 uintset.cpp along with a makefile for the supplied test = harness.

Deliverables: uintset.h, = uintset.cpp,=20 makefile


See lecture notes

Procedural Requirements:

  1. Design the class UIntSet

  2. Implement the class UIntSet with the class definition in file=20 uintset.h and the class implementation in file=20 uintset.cpp

  3. Thoroughly test class UIntSet, starting out with the supplied test = harness=20 in file hw4/test.cpp using command line compile

  4. Write a makefile that builds test.x with the “in lieu of = makefile”=20 include statement commented out or removed

  5. Test the executable again, and refine your work to withstand = testing.

  6. Turn in uintset.h, uintset.cpp, and = makefile=20 using the hw4submit.sh submit script.

Warning: Submit scripts do not work on the = program and=20 linprog servers. Use shell.cs.fsu.edu to submit = projects. If=20 you do not receive the second confirmation with the contents of your = project,=20 there has been a malfunction.

Technical Requirements and Specifications

  1. The class should implement the following diagram:=20

    Class Name:


    Services :

      void        Insert   ( unsigned long n )        // =
    inserts n into set
      void        Remove   ( unsigned long n )        // removes n from set
      void        Clear    ()                         // makes set empty
      bool        Member   ( unsigned long n ) const  // returns true iff n =
    is in set
      bool        Empty    () const;   // true iff set is empty
      size_t      Size     () const;   // returns number of elements in set
      size_t      Range    () const;   // returns upper bound of =
    range/universe [0,ub)
      UIntSet& operator =3D  (const UIntSet& s);  // set =3D s =
    (assignment operator)
      UIntSet& operator +=3D (const UIntSet& s);  // set =3D set =
    union s
      UIntSet& operator *=3D (const UIntSet& s);  // set =3D set =
    intersection s
      UIntSet& operator -=3D (const UIntSet& s);  // set =3D set =
    difference s

    Properties :

      Constructable: objects can be declared as ordinary =
    variables, max size may be specified
      Assignable:    objects can be assigned one to another
      Passable:      objects can be passed by value to and returned as =
    values from functions  

    Private variables:

      size_t         size_;  // the size of the current set
      fsu::BitVector bv_;    // bit vector representing set

    Global operators:

      UIntSet operator + (const UIntSet& s1, const =
    UIntSet& s2);  // returns s1 union s2
      UIntSet operator * (const UIntSet& s1, const UIntSet& s2);  // =
    returns s1 intersection s2=20
      UIntSet operator - (const UIntSet& s1, const UIntSet& s2);  // =
    returns s1 difference s2
      std::ostream& operator << (std::ostream& os, const =
    UIntSet& s); // output operator
  2. The class should be a proper type, to include default and = 1-argument=20 constructor, copy constructor, assignment operator, and destructor. = The=20 constructor argument sets the maximum size of unsigned integers that = can=20 belong to the set. Default maximum element size is 64.

  3. The output operator operator<< should be overloaded = for the=20 type UIntSet. Output should be “{ 0 6 12 18 }” for = the set=20 containing elements 0, 6, 12, 18.

  4. Global binary operators operator+, operator*,=20 operator- should be overloaded for the type UIntSet. = The=20 syntax and semantics of these operators are as follows:

UIntSet(200) s1, s2, s3; // three empty sets with =
range [0,1,2,...,200)
s2.Insert(2); s2.Insert(3); s2.Insert(4);
s3.Insert(2); s3.Insert(4); s3.Insert(6);
std::cout << s2;  // prints { 2 3 4 }
s1 =3D s2 + s3; // s1 is the set union of s2 and s3
std::cout << s1;  // prints { 2 3 4 6 }
s1 =3D s2 * s3; // s1 is the set intersection of s2 and s3
std::cout << s1;  // prints { 2 4 }
s1 =3D s2 - s3; // s1 is the set difference of s2 and s3
std::cout << s1;  // prints { 3 }
  1. UIntSet should pass testing with the supplied hw4/test.cpp = with no=20 compile or runtime errors and no compiler warnings when the warning = flags=20 -W, -Wall, -Wextra are set.

  2. Building and running the supplied hw4/test.cpp should = result in=20 output identical to the supplied executable = area51/settest_?.x [? =3D=20 i or s] .