In: Computer Science
Python
Create a move function that is only defined in the base class called Objects. The move function will take two parameters x,y and will also return the updated x,y parameters.
Python Code :
class Simple:
x = 0
y = 0
def __init__(self,x, y):
self.x = x
self.y = y
def move(self, x, y):
self.x = x
self.y = y
return [x,y]
obj = Simple(1,2)
print("old x value = " , obj.x)
print("old y value = " , obj.y)
a,b = obj.move(13,14)
print("Updated x value = " , a)
print("Updated y value = " , b)
Ouput :