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
feat(ch 5): ejemplos vistos en clase sobre abstracción y static
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user