/* Stack.h provides a Stack class.
 *
 * Basic operations:
 *   Constructor:  Constructs an empty stack
 *   empty:   Checks if a stack is empty
 *   push:    Modifies a stack by adding a value at the top
 *   top:     Accesses the top stack value; leaves stack unchanged
 *   pop:     Modifies a stack by removing the value at the top
 *   display: Displays all the stack elements
 * Class Invariant:
 *   1. The stack elements (if any) are stored in positions
 *      0, 1, . . ., myTop of myArray.
 *   2. -1 <= myTop <= STACK_CAPACITY 
 ------------------------------------------------------------------*/

#ifndef STACK
#define STACK

const int STACK_CAPACITY = 128;
typedef int StackElement;

class Stack
{

/***** Function Members *****/
public:
/* --- Constructor ---
 *
 * Precondition:  A stack has been declared.
 * Postcondition: The stack has been constructed as an 
 *                 empty stack.
 ************************************************************/

Stack();

/* --- Is the Stack empty? ---
 * Receive: Stack containing this function (implicitly)
 * Returns: True iff the Stack containing this function is empty
 *****************************************************************/

bool empty() const;


/***** Data Members *****/
 private:
  StackElement myArray[STACK_CAPACITY];
  int myTop;

}; // end of class declaration

//--- Definition of Class Constructor
inline Stack::Stack() 
{ myTop = -1; } 


//--- Definition of empty
inline bool Stack::empty() const
{ return (myTop == -1); } 


#endif
