#include <iostream>
#include <string>
#include "stack.h"

using namespace std;

int main( int argc, char *argv[] ) {

	int input;	
	cout << "Enter the stack size: ";
	cin >> input;
	Stack stack(input);
	
	string command;	
	do{
		cout << ">";
		cin >> command;		
		if( "sum" == command ){
			cout << stack.sum() << endl; 
		}else if( "push" == command ){
			int value;
			cin >> value;
			try{
				stack.push(value);
			}catch(overflow of){
				cout << "stack is full";
			}
		}else if( "pop" == command ){
			try{
				cout << stack.pop() << endl;
			}catch(underflow of){
				cout << "stack is empty" << endl;
			}
		}else if( "print" == command ){
			cout << stack << endl;
		}
	}while("exit" != command);
	
	cout << "Exiting.." << endl;
}