eliminato classi superflue del progetto e risolto qualche bug. c'è ancora del lavoro da fare sulla queue e deque
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package stack;
|
||||
|
||||
import exceptions.EmptyStackException;
|
||||
import exceptions.FullStackException;
|
||||
import stack.utility.Node;
|
||||
|
||||
/**
|
||||
@@ -15,7 +14,7 @@ import stack.utility.Node;
|
||||
public class NodeStack<E> implements Stack<E> {
|
||||
|
||||
@Override
|
||||
public void push(E element) throws FullStackException {
|
||||
public void push(E element) {
|
||||
Node<E> temp = new Node<E>(element,stack);
|
||||
stack = temp;
|
||||
++number_of_elements;
|
||||
@@ -60,6 +59,24 @@ public class NodeStack<E> implements Stack<E> {
|
||||
return number_of_elements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String to_return = "";
|
||||
to_return = to_return + "[";
|
||||
|
||||
for ( Node<E> temp = stack; temp != null ; temp = temp.getNext()){
|
||||
|
||||
if ( temp.getNext() == null){
|
||||
to_return+=(temp.getElement().toString());
|
||||
}else{
|
||||
to_return+=( temp.getElement().toString() + ",");
|
||||
}
|
||||
}
|
||||
to_return = to_return + "]";
|
||||
|
||||
return to_return;
|
||||
}
|
||||
|
||||
|
||||
private Node<E> stack = null;
|
||||
private int number_of_elements = 0;
|
||||
|
||||
Reference in New Issue
Block a user