feat(ch 5): ejemplos vistos en clase sobre abstracción y static

This commit is contained in:
Rafa Muñoz
2024-12-05 14:26:27 +01:00
parent bdbffee001
commit 34c1985250
6 changed files with 115 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package tutorialJava.capitulo5.ej04_EjemploAbstraccionFiguras;
public class Rectangulo extends Figura {
private float base;
private float altura;
public Rectangulo(float base, float altura) {
this.base = base;
this.altura = altura;
}
@Override
public float calcularArea() {
return this.base * this.altura;
}
@Override
public float calcularPerimetro() {
return 2 * this.base + 2 * this.altura;
}
}