Skip to content

Instantly share code, notes, and snippets.

@felipecastrosales
Created November 25, 2021 22:53
Show Gist options
  • Save felipecastrosales/8fb69ad88d38e1e99d23e8014104c734 to your computer and use it in GitHub Desktop.
Save felipecastrosales/8fb69ad88d38e1e99d23e8014104c734 to your computer and use it in GitHub Desktop.
Herança - POO.dart
void main(){
Cachorro doge = Cachorro('Doge');
print(doge.nome);
doge.latir();
Gato gato = Gato('Paulo');
print(gato.nome);
gato.miar();
}
class Animal {
String? nome;
Animal(this.nome);
void comer() {
print('$nome come');
}
}
class Cachorro extends Animal {
Cachorro(String? nome) : super(nome);
void latir(){
print('O cachorro late!');
}
}
class Gato extends Animal {
Gato(String? nome) : super(nome);
void miar(){
print('O gato mia!');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment