Created
November 17, 2023 05:50
-
-
Save snowmerak/76657540832232f15d522e25140f9844 to your computer and use it in GitHub Desktop.
This file contains 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(List<String> arguments) { | |
Animal dog = Dog(); | |
Animal cat = Cat(); | |
live(dog); | |
live(cat); | |
} | |
void live(Animal animal) { | |
animal.breathe(); | |
} | |
abstract class Animal { | |
void breathe(); | |
} | |
class Dog implements Animal { | |
@override | |
void breathe() { | |
print('Dog is breathing'); | |
} | |
} | |
class Cat implements Animal { | |
@override | |
void breathe() { | |
print('Cat is breathing'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment