Created
November 26, 2021 00:07
-
-
Save felipecastrosales/dc5e765cd825b0c3a47802dbc9bf9e58 to your computer and use it in GitHub Desktop.
Classes Abstratas - POO 2
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(){ | |
// Isso não é mais possível | |
// Animal animal = Animal(); | |
// animal.comunicacao(); | |
Cachorro doge = Cachorro(); | |
doge.comunicacao(); | |
Gato gato = Gato(); | |
gato.comunicacao(); | |
} | |
abstract class Animal { | |
void comunicacao(); | |
} | |
class Cachorro extends Animal { | |
@override | |
void comunicacao() { | |
print('O cachorro se comunica: latindo'); | |
} | |
} | |
class Gato extends Animal { | |
@override | |
void comunicacao() { | |
print('O gato se comunica: miando'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment