-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.lsp.py
More file actions
38 lines (26 loc) · 685 Bytes
/
3.lsp.py
File metadata and controls
38 lines (26 loc) · 685 Bytes
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
"""
Liskov Substitution Principle
Uma subclasse deve ser substituível pela sua superclasse
"""
class Animal:
def __init__(self, name: str):
self.name = name
def get_name(self) -> str:
return self.name
def leg_count(self) -> int:
return 0
class Lion(Animal):
def __init__(self):
super().__init__('lion')
def leg_count(self):
return 4
class Snake(Animal):
def __init__(self):
super().__init__('snake')
def leg_count(self):
print('I have no legs, dummy')
def animal_leg_count(animals: list):
count = 0
for animal in animals:
count += animal.leg_count()
return count