-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathexample.py
55 lines (36 loc) · 811 Bytes
/
example.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""Example"""
from enum import Enum
from implements import Interface, implements
class Direction(Enum):
N = 'North'
W = 'West'
S = 'South'
E = 'East'
class Flyable(Interface):
def fly(self):
pass
def migrate(self) -> Direction:
pass
class Quackable(Interface):
echoes = None
def quack(self):
pass
class Animal:
def __init__(self, name):
self.name = name
@implements(Flyable)
class BaldEagle(Animal):
def fly(self):
pass
def migrate(self) -> Direction:
return Direction.W
@implements(Flyable)
@implements(Quackable)
class MallardDuck(Animal):
echoes = True
def fly(self):
pass
def quack(self):
print("quack!")
def migrate(self) -> Direction:
return Direction.S