Created
July 2, 2020 14:16
-
-
Save shivanchalaeologic/7d46d908d727dd6f3f3d774565666973 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
mixin Swim { | |
void swim() => print('Swimming'); | |
} | |
mixin Bite { | |
void bite() => print('Chomp'); | |
} | |
mixin Crawl { | |
void crawl() => print('Crawling'); | |
} | |
abstract class Reptile with Swim, Crawl, Bite { | |
void hunt(food) { | |
print('${this.runtimeType} -------'); | |
swim(); | |
crawl(); | |
bite(); | |
print('Eat $food'); | |
} | |
} | |
class Alligator extends Reptile { | |
// Alligator Specific stuff... | |
} | |
class Crocodile extends Reptile { | |
// Crocodile Specific stuff... | |
} | |
class Fish with Swim, Bite { | |
void feed() { | |
print('Fish --------'); | |
swim(); | |
bite(); | |
} | |
} | |
main() { | |
Crocodile().hunt('Deer'); | |
Alligator().hunt('Fish'); | |
Fish().feed(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment