// setOfIntegers.cpp   P. Conrad   11/08/04   for CISC181
// a class for a set of integers

#include <iostream>
using namespace std;

#include "setOfIntegers.h"

SetOfIntegers::SetOfIntegers()  // default constructor, construct empty set {}
{
  currentMaxSize = 10;
  currentSetSize = 0;
  members = new int [currentMaxSize]; 
  // allocates space from the heap
}

SetOfIntegers::SetOfIntegers(int x)  // constructor for a singleton set

{
  currentMaxSize = 10;
  currentSetSize = 1;
  members = new int [currentMaxSize]; 
  // allocates space from the heap
  members[0] = x;
}

SetOfIntegers::~SetOfIntegers()  // destructor

{
  delete members []; // delete array; return the space to the heap
}

void SetOfIntegers::print() const  // print, for example {2, 3, 4} not {2, 3, 4, }
{

  cout << "{";
 
  for (int i=0; i<currentSetSize-1 ; i++)
    {
      cout << member[i] << ", ";
    }
  cout << member[currentSetSize-1] << "}"
    
}

bool SetOfIntegers::isEmpty() const  // return true if the set is empty
{

  if (currentSetSize == 0)
    return true;
  else
    return false;

}


void SetOfIntegers::addToSet(int x)  // add x to the set
{

  if (isMemberOf(x))
    return;
  // post condition: x is not already in the set
  // so add it to the end.

  if (currentSetSize == currentMaxSize)
    {
      cerr << "Sorry, set is too big; you need to rewrite your code " << endl;
      exit(-1); // @@@ fix this later... we can do better than this
    }
    
}

