CS 153 Data Structures I
Programming Assignment #6
Due: 9/27/01
This programming assignment is designed to introduce the use of Link Lists
to:
- implement a List data structure container
- continue the use of a ListBox
- introduce the use of 'Nodes' that make up the elements in the List
NOTE ON THE USE OF PREVIOUS FILES - Don't
You will probably want to use much of the code that you developed for assignment
#4. To do that, follow these suggestions
- Create your new project 6
- Copy/paste the .h and .cpp files from assignment 4 into your new project
6 directory
- From the 'file' view, right click on the ProjectFiles entry and select 'Add
file to project'
- Modify the copied files to meet the new specifications
In order to meet these goals you will keep the user interface from Assignment
#4
- an edit box for entering a CString
- an edit box for displaying messages (type CString)
- a button labeled Insert
- a button labeled Find
- a button labeled Remove
- a button labeled Empty?
- a button labeled Full?
- a ListBox
Since 'Nodes' make up the elements of the list you will need to define either
a Class or Struct of type Node. It should contain the following members:
- Node(); // Default constructor
- Node(CString arg); // An overloaded constructor
- CString m_data; // The data in the list is held in individual Nodes
- Node * m_next; // A pointer to the next Node in the list
- Node * m_previous; // A pointer to the previous Node in the list
Your Class CList should contain the same public member functions as Assignment
#4. The m_data member should be renamed to m_Head of type Node *; i.e. m_Head
will be the address of the 1st Node in the list. Be sure to remember to have
the CList() constructor initialize m_Head to NULL.
The behavior of your program should be as follows:
- When Button Insert is clicked the CString in the edit box is added to the
'list' by dynamically allocating a new Node, put the CString into the Node's
m_data field and the contents of the List should be displayed in the ListBox.
- When Button Find is clicked you should search the 'list' for the CString
that was specified in the edit box and display SUCCESS or FAILURE in
the Message-edit-box
- When Button Remove is clicked you should
- Find a Node that contains a matching CString
- Delete the Node from the list
- If the Node had a 'next' and a 'previous' Node be sure to make them
point to each other
- If the List was modified, the contents of the List should be redisplayed
in the ListBox and REMOVED should be displayed in the Message-edit-box.
If it was not present, NOT FOUND should be displayed in the Message-edit-box.
- When Button Empty? is clicked a message should appear indicating TRUE or
FALSE
- When Button Full? is clicked a message should appear indicating TRUE or
FALSE
Testing:
- Click Empty
- Click Full
- Click Remove
- Insert a CString
- Click Empty
- Click Full
- Click Find
- Click Remove
- Click Find
- Click Empty
- Click Full
Follow the above steps BEFORE you even try inserting 2 or more items into the
list. When the list goes from 'empty' to have 1 Node in the list is one of the
hardest places to get correct.