push and pop implemented

This commit is contained in:
Tim 2020-09-10 11:04:22 +02:00
parent 32efc279c7
commit 66b0010484
2 changed files with 7 additions and 2 deletions

Binary file not shown.

View File

@ -8,11 +8,16 @@ public class Stack<ContentType> {
public void push( ContentType pContentObject ) {
// TODO: Implementiere push
if (head != null) {
StackNode<ContentType> node = new StackNode<ContentType>(pContentObject);
node.setNext(head);
head = node;
} else {
head = new StackNode<ContentType>(pContentObject);
}
}
public void pop() {
// TODO: Implementiere pop
if( head != null ) {
head = head.getNext();
}