-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmixins.dart
39 lines (28 loc) · 832 Bytes
/
mixins.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
void main() {
final pato = new Pato();
pato.volar();
final delfine = new Delfine();
delfine.nadar();
}
//clases principales
abstract class Animal {}
abstract class Mamifero extends Animal {}
abstract class Ave extends Animal {}
abstract class Pez extends Animal {}
/*Mis MIXINS
* https://medium.com/flutter-community/dart-what-are-mixins-3a72344011f3
* */
abstract class Volador {
void volar() => print("Estoy Volando!");
}
abstract class Nadador {
void nadar() => print("Estoy Nadando!");
}
abstract class Caminante {
void caminar() => print("Estoy Caminando!");
}
//clases que puedo instancear
class Delfine extends Mamifero with Nadador {}
class Murcielago extends Mamifero with Volador, Caminante {}
class Pato extends Ave with Volador, Nadador, Caminante {}
class Tiburon extends Pez with Nadador {}