-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path#Animal.py
More file actions
37 lines (29 loc) · 1.08 KB
/
#Animal.py
File metadata and controls
37 lines (29 loc) · 1.08 KB
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
#Animal
from doctest import OutputChecker
class Animal():
def __init__(self, color, number_of_legs):
self.species = self.__class__.__name__
self.color = color
self.number_of_legs = number_of_legs
def__repr__(self):
return f'{self.color}{self.species}, {self.number-of_legs} legs'
class Wolf(Animal):
def __init__(self, color, number_of_legs):
super().__init__(color, number_of_legs)
class Sheep(Animal):
def __init__(self, color, number_of_legs):
super().__init__(color, number_of_legs)
class Snake(Animal):
def __init__(self, color, number_of_legs):
super().__init__(color, number_of_legs)
class Cage():
def __init__(self, id_number):
self.id_number = id_number
self.animals= []
def add_animals(self,*animals):
for one_animal in animals:
self.animals.append(one_animal)
def __repr__(self):
output = f'Cage {self.id_number}\n'
output+= '\n'.join('\t' + str(animal)for animal in self.animals)
return output