Created with <3 with dartpad.dev.
Created
October 26, 2023 02:09
-
-
Save leonus96/fbcf0f3a4c7eb3c4f9f543e6e3d6944c to your computer and use it in GitHub Desktop.
POO: rectangulo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rectangulo { | |
double largo; | |
double ancho; | |
Rectangulo({required this.largo, required this.ancho}); | |
double calcularArea() { | |
return largo * ancho; | |
} | |
double calcularPerimetro() { | |
return 2 * (largo + ancho); | |
} | |
} | |
void main() { | |
final Rectangulo r1 = Rectangulo(ancho: 5, largo: 6); | |
print('Area del rectangulo es: ${r1.calcularArea()}'); | |
print('Perimetro del rectangulo es: ${r1.calcularPerimetro()}'); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment