CS 153 Data Structures I
Programming Assignment #3

Due: 2/1/01

This programming assignment is designed to:

In order to meet these goals you must create a VC++ GUI that contains the following items: Plus the following additional window: The behavior of your program should be as follows: Hints for organizing your code:
Your program should be organized with Bag.h containing the Bag class declaration and Bag.cpp containing the Bag functions definitions:  The following functions should be public
  1. Bag();            //    The constructor. Should initialize m_size
  2. void Insert(int)
  3. bool Find(int)
  4. bool Remove(int)
  5. bool isEmpty()
  6. bool isFull()
  7. void Display(CListBox &)


The following data should be private:

  1. int m_data[10];
  2. int m_size;
The OnBUTTONxx functions should of course be located in the ...Dlg class

    Your OnBUTTONInsert might look like:
        void CProg3Dlg::OnBUTTONInsert()
        {
             UpdateData(TRUE);
             my_bag.Insert(m_Input);        //my_bag is a member variable of your ...Dlg class
                                                        //m_Input is the value from you Edit Box
             my_bag.Display(m_OutputListing);            // Discussed below
             UpdateData(FALSE);
        }

The Display(..) function will get called from both OnButtonInsert and OnButtonRemove.  It must pass the CListBox (since the ListBox belongs to the ...Dlg class and the Display(...) function is a member of the Bag class.  The Display function might look like the following.

void Bag::Display(CListBox & listing )
{
     char temp[20];                                // used to pass a value to the ListBox
     listing.ResetContent();
     for( int i = 0; i < m_size; ++i )
     {
         itoa(m_data[i], temp,10);
         listing.AddString(temp);
     }
}
Setting up the ListBox

  1. Drag a ListBox to your dialog window
  2. Use properties to Name it and TURN OFF THE SORTED OPTION
  3. Use the class wizard to assign a member variable name (m_OutputListing) to it like you did with the edit box, but the category must be CONTROL
  4. The Display function above shows you how to 'put stuff into the ListBox'