/*  File: mainstack.C

    Main program that uses the stack ADT.
*/

#include <stdio.h>
#include <stdlib.h>
#include "stringitem.h"
#include "stack.h"

main() {

Stack *ToDo ;
data str ;
int depth ;

   ToDo = new Stack ;

   ToDo->Push("Grade Projects") ;
   ToDo->Push("Write Web Lecture Notes") ;
   ToDo->Push("Grade Exams") ;
   ToDo->Push("Make Slides") ;

   str = ToDo->Top() ;
   printf("Next item: %s\n", str) ;
   free(str) ;

   ToDo->Push("Faculty Meeting") ;
   ToDo->Push("Letter of Recommendation") ;

   str = ToDo->Pop() ;
   printf("\nFinished item: %s\n", str) ;
   free(str) ;

   depth = ToDo->Depth() ;
   printf("\nThere are %d items left in the stack\n", depth) ;

   printf("\nThe rest of the stack contains:\n") ;
   ToDo->Print() ;

   printf("\nEventually...\n") ;
   while( !ToDo->IsEmpty() ) {
     str = ToDo->Pop() ; 
     printf("Finished: %s\n", str) ;
     free(str) ;
   }

   delete ToDo ;
}
