From 9eb04623c403ab86abe33f1495315e0de13cea1d Mon Sep 17 00:00:00 2001 From: Javier Ferreira Date: Tue, 2 Nov 2021 16:56:35 -0300 Subject: [PATCH] Initial commit --- Dia 2/Stack1.java | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Dia 2/Yearbisiesto.java | 39 +++++++++++++++++++++++++++++++++++++++ Dia 4/Ejercicio de formas/Cartel.java | 33 +++++++++++++++++++++++++++++++++ Dia 4/Ejercicio de formas/Circulo.java | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ Dia 4/Ejercicio de formas/Forma.java | 16 ++++++++++++++++ Dia 4/Ejercicio de formas/J.java | 31 +++++++++++++++++++++++++++++++ Dia 4/Ejercicio de formas/Rectangulo.java | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 382 insertions(+) create mode 100644 Dia 2/Stack1.java create mode 100644 Dia 2/Yearbisiesto.java create mode 100644 Dia 4/Ejercicio de formas/Cartel.java create mode 100644 Dia 4/Ejercicio de formas/Circulo.java create mode 100644 Dia 4/Ejercicio de formas/Forma.java create mode 100644 Dia 4/Ejercicio de formas/J.java create mode 100644 Dia 4/Ejercicio de formas/Rectangulo.java diff --git a/Dia 2/Stack1.java b/Dia 2/Stack1.java new file mode 100644 index 0000000..bbc3b95 --- /dev/null +++ b/Dia 2/Stack1.java @@ -0,0 +1,154 @@ +/* + * 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