void main() { Dog dog = Dog(); dog.name = '小狗'; dog.public(); dog.swim(); dog.walk(); } abstract class Animal { String name; void public(); } abstract class SwimAbility { void swim(); } abstract class WalkAbility { void walk(); } //implements接口和extends配合实现类似java的多继承 class Dog extends Animal implements SwimAbility, WalkAbility { @override void public() { print('动物的名字是:$name'); } @override void swim() { print('${name}有游泳的能力'); } @override void walk() { print('${name}有跑步的能力'); } }
部分素材资源来源网站,本站提供免费下载,如有侵权请联系站长马上删除!