我需要创建一个方法 turn_left 来改变朝向,朝向总是从 :south 开始(我正在实现一个移动到板中的机器人)所以如果我调用方法 turn_left 应该将朝向更改为东,然后到北,然后再到西返回南方。我在想这样的事情:
{
0: S
1: E
2: N
3: W
}
这是我的代码
# Models the Robor behavior for the game
class Robot
def initialize(attr = {})
# @position = attr[:position]
# @move = attr[:move]
@facing = :south
# @turn_left =
# @turn_right =
# @errors =
end
def position
end
def move
end
def facing
@facing
end
def turn_left
end
def turn_right
end
def errors
end
end
非常感谢!!!