forked from IF-LK-2020/queue-stack
push and pop implemented
This commit is contained in:
BIN
Stack.class
BIN
Stack.class
Binary file not shown.
@@ -8,11 +8,16 @@ public class Stack<ContentType> {
|
|||||||
|
|
||||||
|
|
||||||
public void push( ContentType pContentObject ) {
|
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() {
|
public void pop() {
|
||||||
// TODO: Implementiere pop
|
|
||||||
if( head != null ) {
|
if( head != null ) {
|
||||||
head = head.getNext();
|
head = head.getNext();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user