/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package stack; import java.util.Scanner; class Stack { private int[] stack; private float[] stackjf; private int cap; private int puntero; public float[] getStackf() { return stackjf; } public void setStackf(float[] stackf) { this.stackjf = stackf; } public int getPointer() { return puntero; } public void setPointer(int pointer) { this.puntero = pointer; } public int getCapacidad() { return cap; } public void setCapacidad(int capacidad) { this.cap = capacidad; } public Stack(int capacidad, int[] stack, float[] stackf){ this.cap = capacidad; this.stack = stack; this.puntero = capacidad - 1; this.stackjf = stackf; } public void push(float number){ if(puntero + 1 == cap){ System.out.println("El stack esta a maxima capacidad"); }else{ this.stack[puntero+1] = (int)number; this.stackjf[puntero+1] = number; puntero++; } } public void push(int number){ if(puntero + 1 == cap){ System.out.println("El stack esta a maxima capacidad"); }else{ this.stack[puntero+1] = number; this.stackjf[puntero+1] = (float)number; puntero++; } } public int pop(){ if(puntero - 1 < -1){ System.out.println("Ya no existen datos en el stack"); }else{ puntero--; return this.stack[puntero+1]; } return -1; } public int[] getStack() { return stack; } public void setStack(int[] stack) { this.stack = stack; } public void printStack(){ for(int i=puntero;i>=0;i--){ System.out.println(stackjf[i]); } } } /** * * @author user */ public class Stack1 { /** * @param args the command line arguments */ public static void main(String[] args) { int choice = 0; int cantidad; int dato; boolean continuar = true; Scanner in = new Scanner(System.in); System.out.println("Rellene la pila: "); cantidad = in.nextInt(); int[] datos = new int[cantidad]; float[] datosf = new float[cantidad]; for(int i=0;i