Inverter pilha em java
ESTOU COM DIFICULDADES EM INVERTER UMA PILHA EN JAVA,
A ASSINATURA DO MÉTODO DEVE SER
public Stack reverse() ,na seguinte classe Starck
package estruturas_sequenciais;
public class Stack {
private Object s[];
private Object d[];
private int top = -1;
public Stack(int size) {
s = new Object;
}
public boolean isEmpty() {
if (top == -1)
return true;
return false;
}
public boolean isFull() {
if (top == s.length - 1)
return true;
return false;
}
public void push(Object obj) throws OverflowException {
if (!isFull()) {
s[++top] = obj;
} else
throw new OverflowException();
}
public Object pop() throws UnderflowException {
if (!isEmpty()) {
Object o = s[top];
s[top] = null;
top--;
return o;
} else
throw new UnderflowException();
}
public void imprime()
{
for(int i = 0; i <= top; i ++)
System.out.print(s*);*
}
public Stack reverse()
throws UnderflowException, OverflowException
{
}
}
Discussão (1)
Carregando comentários...