/** Grundlagen der Informatik
*
Klasse für Stack, verwendet ListNode
*/
public class Stack {
public boolean empty() {
return (liste == null);
}
public Object peek() {
if (empty()) throw new java.util.EmptyStackException();
return liste.e;
}
public void push(Object o) {
ListNode neu = new ListNode(o);
neu.next = liste;
liste = neu;
}
public Object pop() {
if (empty()) throw new java.util.EmptyStackException();
Object temp;
temp = peek();
liste = liste.next;
return temp;
}
protected ListNode liste = null; // Listenkopf
} // Stack