作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们正在尝试构建一个机器人,为了让机器人了解他现在的位置,我们将使用矩阵。
所以我要调出矩阵。没有任何来自 main.java 的东西。然后尝试使用 initMatrix,它只是给我一个错误。
public class Matrix {
// Matrix creation
public String[][] maturix = new String[10][10];
// Recorded Position of the Robot
public int x=0;
public int y=10;
public int Ox;
public int Oy;
public String Orientation = "East"; //Initializing the robot East-oriented to help place Obstacles (either Walls or Sheep) and walking
public void initMatrix()
{
// Summary: E = Empty; G = Sheep; W = Wall; C = current position; F = Finishing Line; X = Null; U = Unknown
maturix[10][0] = "S"; //Starting Position
maturix[10][1] = "U";
maturix[10][2] = "U";
maturix[10][3] = "U";
maturix[10][4] = "U";
maturix[10][5] = "U";
maturix[10][6] = "U";
maturix[10][7] = "U";
maturix[10][8]= "U";
maturix[10][9] = "U";
maturix[10][10] = "U";
maturix[9][1] = "X";
maturix[9][2] = "U";
maturix[9][3] = "X";
maturix[9][4] = "U";
maturix[9][5] = "X";
maturix[9][6] = "U";
maturix[9][7] = "X";
maturix[9][8] = "U";
maturix[9][9] = "X";
maturix[9][10] = "U";
maturix[8][0] = "U";
maturix[8][1] = "U";
maturix[8][2] = "U";
maturix[8][3] = "U";
maturix[8][4] = "U";
maturix[8][5] = "U";
maturix[8][6] = "U";
maturix[8][7] = "U";
maturix[8][8] = "U";
maturix[8][9] = "U";
maturix[8][10] = "U";
maturix[7][0] = "U";
maturix[7][1] = "X";
maturix[7][2] = "U";
maturix[7][3] = "X";
maturix[7][4] = "U";
maturix[7][5] = "X";
maturix[7][6] = "U";
maturix[7][7] = "X";
maturix[7][8] = "U";
maturix[7][9] = "X";
maturix[7][10] = "U";
maturix[6][0] = "U";
maturix[6][1] = "U";
maturix[6][2] = "U";
maturix[6][3] = "U";
maturix[6][4] = "U";
maturix[6][5] = "U";
maturix[6][6] = "U";
maturix[6][7] = "U";
maturix[6][8] = "U";
maturix[6][9] = "U";
maturix[6][10] = "U";
maturix[5][0] = "U";
maturix[5][1] = "X";
maturix[5][2] = "U";
maturix[5][3] = "X";
maturix[5][4] = "U";
maturix[5][5] = "X";
maturix[5][6] = "U";
maturix[5][7] = "X";
maturix[5][8] = "U";
maturix[5][9] = "X";
maturix[5][10] = "U";
maturix[4][0] = "U";
maturix[4][1] = "U";
maturix[4][2] = "U";
maturix[4][3] = "U";
maturix[4][4] = "U";
maturix[4][5] = "U";
maturix[4][6] = "U";
maturix[4][7] = "U";
maturix[4][8] = "U";
maturix[4][9] = "U";
maturix[4][10] = "U";
maturix[3][0] = "U";
maturix[3][1] = "X";
maturix[3][2] = "U";
maturix[3][3] = "X";
maturix[3][4] = "U";
maturix[3][5] = "X";
maturix[3][6] = "U";
maturix[3][7] = "X";
maturix[3][8] = "U";
maturix[3][9] = "X";
maturix[3][10] = "U";
maturix[2][0] = "U";
maturix[2][1] = "U";
maturix[2][2] = "U";
maturix[2][4] = "U";
maturix[2][5] = "U";
maturix[2][6] = "U";
maturix[2][7] = "U";
maturix[2][8] = "U";
maturix[2][9] = "U";
maturix[2][10] = "U";
maturix[1][0] = "U";
maturix[1][1] = "X";
maturix[1][2] = "U";
maturix[1][3] = "X";
maturix[1][4] = "U";
maturix[1][5] = "X";
maturix[1][6] = "U";
maturix[1][7] = "X";
maturix[1][8] = "U";
maturix[1][9] = "X";
maturix[1][10] = "U";
maturix[0][0] = "U";
maturix[0][1] = "U";
maturix[0][2] = "U";
maturix[0][3] = "U";
maturix[0][4] = "U";
maturix[0][5] = "U";
maturix[0][6] = "U";
maturix[0][7] = "U";
maturix[0][8] = "U";
maturix[0][9] = "U";
maturix[0][10] = "5";
}
}
有什么想法吗?
最佳答案
java 中的数组索引是从 0 开始的。
因此,如果您键入 maturix[10][0]
,您将访问第 11 个元素。在声明中加 1,public String[][] maturix = new String[11][11];
关于java - Lejos 在初始化矩阵时给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34157567/
我有一个经典的 ASP 页面 (VBscript),它在服务器端生成 XML,然后 Response.Writes。该页面根本没有客户端。 但是我需要将其转换为 JSON。由于我找不到有效的 ASP
我想从客户端应用程序的 HDFS 中读取特定的 SequenceFile。我可以使用 SequenceFile.Reader 来做到这一点,它工作正常。但是是否也可以通过分析抛出的 IOExcepti
我是一名优秀的程序员,十分优秀!