Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Tarea;
- public class Pila
- {
- private int Tope = -1;
- private int Max;
- private int Pila[];
- public int DatoPila;
- public Pila(int CantMax)
- {
- Pila = new int[CantMax];
- Max = CantMax;
- }
- private boolean PilaVacia()
- {
- boolean resp = false;
- if(Tope == -1)
- resp = true;
- return resp;
- }
- private boolean PilaLlena()
- {
- boolean resp = false;
- if((Tope-1) == Max)
- resp = true;
- return resp;
- }
- public boolean InsertarPila(int Dato)
- {
- boolean resp = false;
- if(!PilaLlena())
- {
- Tope++;
- Pila[Tope] = Dato;
- resp = true;
- }
- return resp;
- }
- public boolean RemoverPila()
- {
- boolean resp = false;
- if(!PilaVacia())
- {
- DatoPila = Pila[Tope];
- Tope--;
- resp = true;
- }
- return resp;
- }
- public boolean VerPila()
- {
- boolean resp = false;
- if(!PilaVacia())
- {
- DatoPila = Pila[Tope];
- resp = true;
- }
- return resp;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement