You are on page 1of 1

/*

* To change this template, choose Tools | Templates


* and open the template in the editor.
*/
package Pila;
/**
*
* @author CURSO
*/
public class Pila {
private char [] P;
private int tope;
private int max=4;
public Pila( int max)
{
P=new char [max];
this.tope= tope-1;
}
public void push (char x)
{// insertar
tope++;
P[tope]=x;

}
public char pop()
{//elimina
char aux =P[tope];
tope--;
return aux;
}
public char stacktop()
{// obtiene el ultimo elemento de la pila
char aux=P[tope];
return aux;
}
public boolean llena()
{
if (tope==max-1)
return true;
else
return false;
}
public boolean vacia()
{
if (tope<=0){
return true;}
else
return false;
}
}

You might also like