Created with <3 with dartpad.dev.
Created
October 26, 2023 01:55
-
-
Save leonus96/80b607422b906b31eb4d544684141a84 to your computer and use it in GitHub Desktop.
POO:persona
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
/// Programación Orienta a Objetos | |
/// CLASE: Una plantilla para crear objetos. | |
/// Sintaxis: | |
/// class NombreDeLaClase { | |
/// String propiedad1; | |
/// int propiedad2; | |
/// | |
/// NombreDeLaClase() { | |
/// | |
/// } | |
/// | |
/// void metodo1() { | |
/// | |
/// } | |
/// | |
/// void metodo2() { | |
/// | |
/// } | |
/// } | |
class Persona { | |
String nombre; | |
int edad; | |
int talla; | |
String dni; | |
bool sexo; | |
Persona( | |
this.nombre, | |
this.edad, | |
this.talla, | |
this.dni, | |
this.sexo, | |
); | |
void saludar() { | |
print('Hola, mi nombre es $nombre y tengo $edad años'); | |
} | |
} | |
void main() { | |
final Persona profesor = Persona( | |
'Joseph', | |
27, | |
167, | |
'73033257', | |
true, | |
); | |
final Persona alumno = Persona( | |
'Katerin', | |
25, | |
165, | |
'53627536', | |
false, | |
); | |
profesor.saludar(); | |
alumno.saludar(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment