I have a problem with my homework. And I need all the help that you can give me.
i need to create a combination of a stack that can store any type of data and a Stack that works with elements of type Stack. I´m very confused.
The methods that I was supposed to implement were:
initializeStack() isEmpty() isFull() Push() Pop() showStack() countElements()
And this is what i have so far:
public class pilita {
Object vectorPila[];
int tope;
public pilita(int tam){
vectorPila=new Object[tam];
tope=-1;
}
public void inicializarPila(){
tope=-1;
}
public void push(Object dato){
tope++;
vectorPila[tope]=dato;
}
public Object pop(){
Object fuera=vectorPila[tope];
tope--;
return fuera;
}
public boolean pilaVacia(){
return tope==-1;
}
public boolean pilaLlena(){
return vectorPila.length-1==tope;
}
public Object cima(){
return vectorPila[tope];
}
public Object contar(){
return tope+1;
} }
All the methods are well implemented (Using my logic).
But how can i make an Stack using Stack data type using those methods?. I would be very grateful if anyone could help me.
Also here is the original problem.
Stack of little Stacks: The elements of the Data Structure Little Stack are of any type of data. The elements of the Data Structure Stack are of Stack type.