Skip to content

Commit c5516c8

Browse files
committed
No need to define __init__ in Wolf, Sheep, Snake, Parrot classes
1 parent 4f956bd commit c5516c8

1 file changed

Lines changed: 6 additions & 18 deletions

File tree

ch09-objects/e43b1_legged_animals.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,34 @@ def __repr__(self):
1515

1616

1717
class TwoLeggedAnimal(Animal):
18+
number_of_legs = 2
19+
1820
def __init__(self, color):
1921
super().__init__(color)
20-
self.number_of_legs = 2
2122

2223

2324
class FourLeggedAnimal(Animal):
25+
number_of_legs = 4
26+
2427
def __init__(self, color):
2528
super().__init__(color)
26-
self.number_of_legs = 4
2729

2830

2931
class ZeroLeggedAnimal(Animal):
32+
number_of_legs = 0
33+
3034
def __init__(self, color):
3135
super().__init__(color)
32-
self.number_of_legs = 0
3336

3437

3538
class Wolf(FourLeggedAnimal):
3639
"""Class for creating 4-legged wolves of any color"""
3740

38-
def __init__(self, color):
39-
super().__init__(color)
40-
41-
4241
class Sheep(FourLeggedAnimal):
4342
"""Class for creating 4-legged sheep of any color"""
4443

45-
def __init__(self, color):
46-
super().__init__(color)
47-
48-
4944
class Snake(ZeroLeggedAnimal):
5045
"""Class for creating 0-legged snakes of any color"""
5146

52-
def __init__(self, color):
53-
super().__init__(color)
54-
55-
5647
class Parrot(TwoLeggedAnimal):
5748
"""Class for creating 2-legged parrots of any color"""
58-
59-
def __init__(self, color):
60-
super().__init__(color)

0 commit comments

Comments
 (0)