Skip to content

Instantly share code, notes, and snippets.

@snowmerak
Created November 17, 2023 05:50
Show Gist options
  • Save snowmerak/76657540832232f15d522e25140f9844 to your computer and use it in GitHub Desktop.
Save snowmerak/76657540832232f15d522e25140f9844 to your computer and use it in GitHub Desktop.
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