Refactor di tutto lo stack. Manca l'esercizio sulle operazioni matematiche via stack. Sulla coda bisogna implementare da zero FixedArrayQueue e poi la relativa versione senza fullexception in ArrayQueue. Esercizi!

This commit is contained in:
2014-03-17 12:11:39 +01:00
parent d60e74a09c
commit 08069c6b46
17 changed files with 318 additions and 95 deletions

View File

@@ -1,6 +1,6 @@
package stack;
import exceptions.EmpyStackException;
import exceptions.EmptyStackException;
import exceptions.FullStackException;
/**
@@ -11,15 +11,15 @@ import exceptions.FullStackException;
*/
public class FixedArrayStack<E> extends StackRules<E> {
public class FixedArrayStack<E> implements Stack<E> {
public FixedArrayStack(){
public FixedArrayStack(){
stack = (E[])new Object[dcapacity];
}
public FixedArrayStack( int size){
public FixedArrayStack(int size){
stack = (E[])new Object[size];
@@ -34,16 +34,16 @@ public class FixedArrayStack<E> extends StackRules<E> {
}
@Override
public E top() throws EmpyStackException {
public E top() throws EmptyStackException {
if (isEmpty())
throw new EmpyStackException();
throw new EmptyStackException();
return stack[top];
}
@Override
public E pop() throws EmpyStackException {
public E pop() throws EmptyStackException {
if (isEmpty())
throw new EmpyStackException();
throw new EmptyStackException();
return stack[top--];
}