#include "strlist.h"
#include <iostream.h>

/*******************************************************************\
 This driver outputs the following:

1 ********************************************************
getCount() returned  0
isEmpty() returned 1
2 ********************************************************
getCount() returned  3
isEmpty() returned 0
One 
Two 
Three 
3 ********************************************************
One Two Three 
4 ********************************************************
Five Four One Two Three 
5 ********************************************************
isPresent("Four") returned 1
isPresent("Seven") returned 0
6 ********************************************************
getItem(3) returned One
7 ********************************************************
getItem(10) returned NULL
8 ********************************************************
Five Four Two Three 
9 ********************************************************
Five Four Two Three 
10********************************************************
This line is going to be trunc 
Five 
Four 
Two 
Three 
11 *******************************************************
Displaying the list:
Done.


\*****************************************************************/

void main(void)
{
  StrList list;


  cout << "1 ********************************************************" << endl;
  cout << "getCount() returned  " << list.getCount() << endl;
  cout << "isEmpty() returned " << list.isEmpty() << endl;


  list.Append("One");
  list.Append("Two");
  list.Append("Three");


  cout << "2 ********************************************************" << endl;
  cout << "getCount() returned  " << list.getCount() << endl;
  cout << "isEmpty() returned " << list.isEmpty() << endl;
  list.Display();


  cout << "3 ********************************************************" << endl;
  list.Display(FALSE);
  

  list.Prepend("Four");
  list.Prepend("Five");


  cout << "4 ********************************************************" << endl;
  list.Display(FALSE);


  cout << "5 ********************************************************" << endl;
  cout << "isPresent(\"Four\") returned " << list.isPresent("Four") << endl;  
  cout << "isPresent(\"Seven\") returned " << list.isPresent("Seven") << endl;  


  const char *s1 = list.getItem(3);
  cout << "6 ********************************************************" << endl;
  if (s1)
    cout << "getItem(3) returned " << s1 << endl;
  else
    cout << "getItem(3) returned NULL" << endl;


  const char *s2 = list.getItem(10);
  cout << "7 ********************************************************" << endl;
  if (s2)
    cout << "getItem(10) returned " << s2 << endl;
  else
    cout << "getItem(10) returned NULL" << endl;


  list.Remove("One");
  cout << "8 ********************************************************" << endl;
  list.Display(FALSE);


  list.Remove("Nine");
  cout << "9 ********************************************************" << endl;
  list.Display(FALSE);

  
  list.Prepend("This line is going to be truncated.");
  cout << "10********************************************************" << endl;
  list.Display();

  
  while (!list.isEmpty())
  {
    const char *s3 = list.getItem(1);
    list.Remove(s3);
  }
  cout << "11 *******************************************************" << endl;
  cout << "Displaying the list:" << endl;
  list.Display();


  cout << "Done." << endl;
}  

