Untitled
unknown
python
3 years ago
753 B
12
Indexable
class AbleToHunt:
def hunt(self, goal):
print(f'Цель: {goal}, объект: {self}')
class AbleToHide:
def hide(self, goal):
print(f'Прячется от: {goal}, объект: {self}')
class Animal:
def __init__(self, name, type):
self.name = name
self.type = type
def __str__(self):
return f'{self.name}, тип: {self.type}'
class Wolf(Animal, AbleToHunt):
def __init__(self, name):
super().__init__(name, 'Волк')
def hunt(self, goal):
super().hunt(goal)
class Rabbit(Animal, AbleToHide):
def __init__(self, name):
super().__init__(name, 'Кролик')
def hide(self, goal):
super().hide(goal)Editor is loading...