package stack;

public class Stack {

	private int index;
	private char [] stack;
	public final static int MAXLENGTH = 50;
	
	public Stack(){
		index= 0;
		stack = new char[MAXLENGTH];
	}
	
	public void push(char elem) throws StackException{
		if(index == MAXLENGTH)
			throw new StackException("Stack ist voll", "Stack ist voll");
		stack[index] = elem;
		index++;
	}
	
	public char pop() throws StackException{
		if(index == 0)
			throw new StackException("Stack ist leer", "Stack ist leer");
		index--;
		return stack[index];
	}
	
	public boolean isEmpty(){
		return index == 0;
	}
	
	public void clear(){
		index = 0;
	}
}


