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:
@@ -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--];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user