class Model():
def __init__(self, name, size):
self.name = name
self.size = size
def crt(self):
return self.name + self.size
class Ball(Model):
def __init__(self,width,height):
self.width = width
self.height = height
def move(self):
return self.width + self.height
play = Ball(200,100)
play.crt() - не сработает
>>> class Model():
... def __init__(self, name, size):
... self.name = name
... self.size = size
... def crt(self):
... return self.name + self.size
...
>>>
class Ball(Model):
def __init__(self,width,height, *args, **kwargs):
self.width = width
self.height = height
super().__init__(*args, **kwargs)
def move(self):
return self.width + self.height
...
>>> play = Ball(200, 100, 2, 3)
>>> play.crt()
5
>>> play.move()
300