package Zavorky;

/**
 * 
 * @author Martin Lipinsky
 *
 */

public class charZasobnikSpoj {
	
	private class item {
		char key;
		item next;
		
		item (char key, item next) {
			this.key = key;
			this.next = next;
		}
	}
	
	item top;
	
	charZasobnikSpoj() {
		this.top = null;
	}
	
	public void push(char number) {
		top = new item(number,top);
	}
	
	public char pop() {
		char c = top.key;
		top = top.next;
		return c;
	}
	
	public boolean empty() {
		return (top == null);
	}
	
	public void prcharln() {
		String S = "";
		if (empty()) {
			S = "Zasobnik je prazdny.";
		} else {
			item P = top;
			while (P != null) {
				S = P.key+S;
				P = P.next;
			}
		}
		System.out.println(S);
	}
}
