salve,
dovrei scrivere una classe ArrayQueue che implementa l'interfaccia TDA Queue usando la classe stack. Le variabili d'istanza sono 2 di tipo stack e devo usare il try-catch. E dovrei fare un piccolo test di funzionamento.
Finora ho scritto questo, ma ci sono sicuramente errori!!! (sono alle prime armi)
Se potete darmi una mano ve ne sarei grato
private QueueStack (S1,S2) {
public ArrayStack() {
S1= NewArrayStack();
S2=NewArrayStack();
}
public QueueStack(int cap) {
S1= NewArrayStack(cap);
}
public int size() {
return a.size();
}
public boolean isEmpty() {
return a.isEmpty();
}
public Object top() throws EmptyStackException {
try {
return Q.front()
}
catch (EmptyQueueException) {
throw new ArrayStackEmptyException("Errore")
}
}
public Object pop() throws StackEmptyException {
try
{
return Q.deque()
}
catch (EmptyQueueException) {
throw new ArrayStackEmptyException("Errore")
}
}
public Object push(Object element) throws StackFullException {
try
{
return Q.enqueue()
}
catch (FullQueueException) {
throw new ArrayStackFullException("Errore")
}
}