Created
November 25, 2021 22:53
-
-
Save felipecastrosales/8fb69ad88d38e1e99d23e8014104c734 to your computer and use it in GitHub Desktop.
Herança - POO.dart
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
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