mirror of
https://gitlab.com/tutorial-java-rafa-munoz/tutorial-java-2024-25/tutorialjava2024-25.git
synced 2025-11-09 18:03:09 +01:00
24 lines
422 B
Java
24 lines
422 B
Java
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;
|
|
}
|
|
|
|
}
|