Skip to content

Instantly share code, notes, and snippets.

@leonus96
Created October 26, 2023 02:09
Show Gist options
  • Save leonus96/fbcf0f3a4c7eb3c4f9f543e6e3d6944c to your computer and use it in GitHub Desktop.
Save leonus96/fbcf0f3a4c7eb3c4f9f543e6e3d6944c to your computer and use it in GitHub Desktop.
POO: rectangulo
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