Homework 7 - Extra Credit

Due: Wednesday March 17, 2009 at noon.
Absolutely NO late assignments will be accepted.
This assignment is worth up to 20 extra credit points in your Homework/Lab grading category.

The purpose of this assignment is to make an integer linked list and stack by inheriting from a general parent list class.

You will define three classes with the following hierarchy, plus a ListNode class for use by List.

              List
           /       \
          /         \
     Linked         Stack
     List

ListNode class

This is the basic node for the list. It holds the data and the pointer to the next node.
Private variables
Public functions

List class

The List class is the base class from which the other two classes are derived. It has no real usable features to the main program. Its purpose is to define common functions the other two classes will use. These common functions are put in the protected section so only the derived classes can access them. It has the following features:
Protected variables
Protected functions
Public functions

LinkedList class

This class takes the base class and creates a fully working linked list. It will expand the base class to allow searching and deleting specific values.
Public functions

Stack class

This will implement a stack that is derived from the base list class. It will define the push and pop functions.
Public functions

Menu Program

Once the classes are defined, code the following nested menu program to test that the classes work. A nested menu program has multiple menus that are selected from a main menu. When the program is first invoked, the main menu is presented. Options on the main menu give access to the sub-menus. For this assignment, use the following main menu:
   Welcome to the CS222 Homework 7 Menu
==============================================
1.  Test the linked list class
2.  Test the stack class

0.  Exit
==============================================
The submenus are defined as follows.

Linked List Menu

This menu will test the linked list class.
               Linked List Menu
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1. Insert a value at the head of the list
2. Search forwards for a value
3. Insert a value after the result of the previous search
4. Delete the first instance of a value
5. Print the list contents

0. Return to main homework menu
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Option 2 should store the result of the previous search so it is available for Option 3. If there is no prior search result available, Option 3 should print an error and return to the menu.

Stack Menu

This menu will test the stack class.
          Stack Menu
---------------------------------
1. Push a value onto the stack
2. Pop a value off of the stack
3. Print the stack contents

0. Return to main homework menu
---------------------------------