//Simple application of ADT List using templates
// File:    list-app3.cc
// Author:  Henry M. Walker
// Date:    May 29, 1998

#include "list-temp.h"
#include "apstring.cpp"

// declaration of two lists of apstrings:
//      one list is unordered, the other is ordered

int main () {
    char choice;
    apstring s;
    List<apstring>     liststr;  // variable declarations, filling in List type
    OrderedList<apstring>  oliststr;

    cout << "program to test List ADT and Ordered List ADT with apstrings" << endl;
    
    do {
        cout << endl << "options" << endl;
        cout << "   a - search for item on apstring list"  << endl;
        cout << "   b - search for item on ordered apstring list" << endl << endl;

        cout << "   e - count items on apstring list"  << endl;
        cout << "   f - count items on ordered apstring list"  << endl << endl;

        cout << "   i - insert string into apstring list"  << endl;
        cout << "   j - insert string into apstring list"  << endl << endl;

        cout << "   p - print apstring list in order" << endl;
        cout << "   q - print ordered apstring list in order" << endl << endl;
        
        cout << "   r - print apstring list from back to front" << endl;
        cout << "   s - print apstring list from back to front" << endl << endl;
        cout << "   x - exit" << endl;

        cout << "   enter choice: ";
        cin >> choice;
        switch (choice) {
 	   case 'a': cout << "enter string for search: ";
                     cin >> s;
                     if (liststr.isin(s))
                        {cout << "string found in list" << endl;}
                        else {cout << "string not found in list" << endl;}
                     break;          
 	   case 'b': cout << "enter string for search: ";
                     cin >> s;
                     if (oliststr.isin(s))
                        {cout << "string found in list" << endl;}
                        else {cout << "string not found in list" << endl;}
                     break;          
          
           case 'e': liststr.count(); break;
           case 'f': oliststr.count(); break;

	   case 'i': cout << "enter string to be inserted: ";
                     cin >> s;
                     liststr.insert(s);
                     break;
	   case 'j': cout << "enter string to be inserted: ";
                     cin >> s;
                     oliststr.insert(s);
                     break;

           case 'p': liststr.print(); break;
           case 'q': oliststr.print(); break;

	   case 'r': liststr.print_reverse(); break;
	   case 's': oliststr.print_reverse(); break;

           case 'x':  cout << "program terminated" << endl; break;
           default:  cout << "invalid option" << endl;
           }
    }
    while (choice != 'x');
    

} /* main */
