I would like to write a program for calculating the distance of an from initial distance x0 and to a distance vot
distance = x0 + v0t
Here is my "intended" code
[code=python]
class distance:
def __init__(self, iniX, iniV):
self._x0= iniX
self._v0= iniV
def setTime(self,t) :
self._t0=t
def result(self):
return self._x0 + self._v0*t
#the result I would like to have
d = distance(5,10)
d.setTime(5)
#d = 5 + 10*5 = 55
>>>55
d.setTime(5)
#d=d(5) [the first distance set by t=5] + vo*5[the new distance set by another t=5]=105
>>>105
[/code]
How can I write the right code?
distance = x0 + v0t
Here is my "intended" code
[code=python]
class distance:
def __init__(self, iniX, iniV):
self._x0= iniX
self._v0= iniV
def setTime(self,t) :
self._t0=t
def result(self):
return self._x0 + self._v0*t
#the result I would like to have
d = distance(5,10)
d.setTime(5)
#d = 5 + 10*5 = 55
>>>55
d.setTime(5)
#d=d(5) [the first distance set by t=5] + vo*5[the new distance set by another t=5]=105
>>>105
[/code]
How can I write the right code?
Comment