

public class StackCheckDecorator 
implements Stack {

	private Stack m_inner;
	
	public StackCheckDecorator (Stack inner) {
		m_inner = inner;
	}
	
	public void push(Object o) {
		if(o == null) {
			System.out.println("You are a bad person: push() does not like nullness.");
			System.exit(-1);
		}
		m_inner.push(o);
	}

	public Object pop() {
		if(m_inner.getLength() <= 0) {
			System.out.println("What are you thinking: pop() does not like to be called on an empty stack.");
			System.exit(-2);
		}
		return(m_inner.pop());
	}

	public Object getTop() {
		if(m_inner.getLength() <= 0) {
			System.out.println("Something's wrong with you: getTop() does not like to be called on an empty stack.");
			System.exit(-2);
		}
		return(m_inner.getTop());
	}

	public int getLength() {
		return(m_inner.getLength());
	}

	public void clear() {
		m_inner = null;
	}

}
