Dovrei implementare un' interfaccia Stack tramite coda.
Il problema č nella pop() e push() che non sto capendo come gestire.
In uno stack la pop e la push vengono fatte sempre in top, mentre nella coda l'estrazione avviene in testa(front) e l'inserimento in rear(coda).
Quindi come posso farla funzionare visto che prevede queste cose fatte in modo diverso?

La classe l'ho scritta cosė:

codice:
public class Queue<E> implements Stack<E>
{
	private int errori=0;
	
	private int size;
	
	private Node <E> top;
	
	private Node<E> front;
	
	private Node<E> rear;
	
	public Queue()
	{
		
		rear=top=null;
		front=rear;
		size=0;
	}
	
	public boolean isEmpty(){return(top==null);}
	
	public int getSize(){return size;}
	
	public E top() throws EmptyStackException
	{
		
		if(isEmpty()) throw new EmptyStackException(errori+" errori generati");
		return rear.getElement();
		
	}
	
	public E pop() throws EmptyStackException
	{
		if(isEmpty()) throw new EmptyStackException(errori+" errori generati");
		E object=front.getElement();
		rear=rear.getNext();
		size--;
		front=null;
		front=rear;
		return object;
	}
	
	public void push(E element)
	{
		Node <E> node=new Node<E>(element, rear);
		rear=node;
		front=rear;
		size++;
	}
}