public class MyStack {

	protected Object rep[];
	protected int top = -1;
	protected int size = 0;
	protected int count = 0;

	public MyStack(int size) {
		if (size > 0) {
			this.size = size;
			rep = new Object[size];
	    }
    }

    public boolean isFull() {
		return (count == size);
    }

    public boolean isEmpty() {
		return (count == 0);
    }

    public int getSize() {
		return size;
    }

    public void push(Object e) {
		if (e != null && !isFull()) {
			 top++;
			 rep[top] = e;
			 count ++;
	    }
    }

    public Object pop(){
		Object result = null;
		if (!isEmpty()){
			result = rep[top];
			top--;
			count--;
	    }
	    return result;
    }

    public static void main(String args[]) {
		MyStack stack = new MyStack(10);
		for (int i = 0; !stack.isFull(); i++) {
			stack.push(new Integer(i));
			System.out.println("push: " + i);
	    }
	    while (!stack.isEmpty()) {
			System.out.println("pop: " + stack.pop());
	    }
    }
}