机器人
我们有我们的好朋友机器人约翰尼,他们迷失在操场上。 他的位置由两个整数坐标表示: X和Y X是水平轴,Y轴是垂直轴(还记得你在学校画的方式吗?) 不幸的是,他有一些未知的随机初始位置,我们甚至不知道初始方向。 但是他确实想回家,这由toX和toY表示。 希望你能弄明白点。
您可以使用以下漫游器的方法:
公共班级机器人{
public Direction getDirection() {
// current robot direction
}
public int getX() {
// current X position
}
public int getY() {
// current Y positon
}
public void turnLeft() {
// turn the robot left for 90 degrees
}
p