CS C++

Assignment 11

Write a program that provides a user interface for manipulating a doubly-linked list. The main program should loop until the user enters a blank string. Each time through the loop, the user will enter a word and indicate whether the word should be inserted into or deleted from the list (by entering "+" or "-" perhaps). Your program should perform the insertion/deletion, then display the elements in the list both forwards and backwards.

Implement the doubly-linked list as a class (just a plain class, not a template class), with the following member and method definitions:


class DLList
{
public:
    DLList();                           // default constructor
    ~DLList();                          // destructor
    void Insert(const apstring& word);  // insert word in proper place
    void Delete(const apstring& word);  // delete word from list
    void ShowList();                    // print words in order
    void ShowListReverse();             // print words in reverse order
private:
    ListItem *first, *last;
}

Remember to put the class definition in a header file, which must be
#included in your main program file. The method implementations go in
their own .cpp file. 

Please submit a printed copy of your code, plus either your program on
disk or a printed sample run. 

A program run might look like this: 

Enter word: hello
Insert (+) or delete (-) ? +
List: hello
Reversed: hello

Enter word: goodbye
Insert (+) or delete (-) ? +
List: goodbye hello
Reversed: hello goodbye

Enter word: howdy
Insert (+) or delete (-) ? +
List: goodbye hello howdy
Reversed: howdy hello goodbye

Enter word: hello
Insert (+) or delete (-) ? -
List: goodbye howdy
Reversed: howdy goodbye

Enter word: hi
Insert (+) or delete (-) ? +
List: goodbye hi howdy
Reversed: howdy hi goodbye

Enter word: