Estou com problemas com um com um código em python, vindo de um curso online, e não estou conseguindo resolver:
class point(object):
def __init__(self, x, y):
self.x = x
self.y = y
class reward(point):
def init(self, x, y, name):
super(reward, self).init(x, y)
self.name = name
class robo:
def init(self, x, y):
self.x = x
self.y = y
def move_up(self, x, y):
if self.y < 10:
self.y = self.y + 1
else:
print("Comando proibido")
def move_down(self, x, y):
if self.y > 1:
self.y = self.y - 1
else:
print("Comando proibido")
def move_left(self, x, y):
if self.x > 1:
self.x = self.x - 1
else:
print("Comando proibido")
def move_right(self, x, y):
if self.x < 10:
self.y = self.y + 1
else:
print("Comando proibido")
def check_rewards(robo, reward):
ok = False
for reward in rewards:
if robo.x == reward.x and reward.y == robo.y:
print("O robô achou a recompensa: {}".format(reward.name))
ok = True
return ok
r1 = reward(1, 2, “moeda”)
r2 = reward(5, 3, “gasolina”)
robot = robo(2, 2)
rewards = [r1, r2]
check_rewards(robo, rewards)
Me ajudem por favor
erros:
Traceback (most recent call last):
File “/home/vitor/PycharmProjects/JogoDoRobo/robojogo.py”, line 66, in
check_rewards(robo, rewards)
File “/home/vitor/PycharmProjects/JogoDoRobo/robojogo.py”, line 52, in check_rewards
if robo.x == reward.x and reward.y == robo.y:
AttributeError: type object ‘robo’ has no attribute ‘x’
Process finished with exit code 1