/* Author Name: Baljeet S. Malhotra */
/* Student ID:  XXXXXXXXXXX         */ 
/* Program Name: class-example1.cpp */
/* Program Description: Example     */
/* Date of creation: 14th Oct. 2004 */
/* Lab section: XX                  */

#include <iostream>
using namespace std;

const int STACK_SIZE = 100;

class Stack {

  private:	// visible only inside the class Stack
	int count;
	int data[STACK_SIZE];

  public:	// visible from anywhere
	void init();
	void push(const int item);
        void display();
	int pop();
};

void Stack::init() {
  count = 0;
}

void Stack::push(const int item) {
  data[count++] = item;
}
int Stack::pop() {
  return data[--count];
}

void Stack::display() {
 for(int i = 0; i < count; i++)
   {
     cout << "item " << i << " is :" << data[i] << endl; 
   } 
}

int main()
{
 int item = 0, choice = 0;

 Stack stack1;
 stack1.init(); //initializin g the stack

 while(choice == 0 || choice == 1)
 {
  if(choice == 0)
  {
    cout << "Enter the item to add on top of the stack : ";
    cin >> item;
    stack1.push(item);     
  }
  else 
  {  
    cout << "You have opted to pop the top item of the stack" << endl;
    item = stack1.pop();
    cout << item << "is deleted from the stack" << endl;
  }

  cout << "Enter your choice for stack push(0) or pop(1) OR (2) to quit : ";
  cin >> choice;

 } 

 cout << "Displaying the updated stack : " << endl; 
 stack1.display();

 return 0;
}
