// File: StackType.cpp

 

#include "StackType.h"

 

 

StackType::StackType()

{

  top = -1;

}

 

bool StackType::IsEmpty() const

{

  return (top == -1);

}

 

bool StackType::IsFull() const

{

  return (top ==  MAX_ITEMS-1);

}

 

void StackType::Push(ItemType newItem)

{

  if( IsFull() )

    cout<<"Fullstack exception thrown";

  else

{

top++;

                        items[top] = newItem;

}

}

 

void StackType::Pop()

{

  if( IsEmpty() )

            cerr<<"Empty exception thrown"<<endl;

  else

top--;

}

 

ItemType StackType::Top()

{

            if (IsEmpty())

            {

                        cerr<<"Empty exception thrown"<<endl;

                        exit(1);

            }

            else

            {

                        return items[top];

            }

}