わかりましたので、私は「眠れない、プログラミングしたほうがいい」ような夜を過ごしています。今のところ、私はおそらく疲れすぎているだけかもしれませんが、それは私を悩ませています. コードで char[] オプションを 8x8 配列に出力しようとしています。メソッドをセットアップしましたが、別の 8 x 8 配列のすぐ下にある別の 8 x 8 配列に出力してしまいます。警告これはおそらく非常に愚かな間違いです。しかし、私は今、すべてのエラーに気付いていないようです。どんな助けでも大歓迎です!ありがとう!
'
static char[] options = {'*','$','@','+','!','&'};
public static void main(String[] args){
System.out.println("How to play: type a row and column index, followed by \n" +
"the direction to move it: u (up), r (right), d (down), l (left)");
char[][] grid = new char[8][8];
drawGrid(grid);
populateRandom(grid,options);
System.out.println("Enter <row> <column> <direction to move> or q to quit");
//char randomChar = 66;
//System.out.println(randomChar);
}
public static void drawGrid(char[][] grid){
System.out.println("\t1 \t2 \t3 \t4 \t5 \t6 \t7 \t8");
System.out.println();
//Random r = new Random();
for(int row=0 ; row < grid.length ; row++) {
//populateRandom(grid,options);
System.out.print((row+1)+"");
for(int column=0 ; column < grid[row].length ; column++){
//populateRandom(grid, options);
}
System.out.println();
}
System.out.println();
}
public static void populateRandom(char[][] grid, char[] options)
{
Random randomGenerator = new Random();
for (int row = 0; row < grid.length; row++){
for (int column=0; column < grid[row].length; column++){
int randomIndex = randomGenerator.nextInt(6);
grid[row][column] = options[randomIndex];
System.out.print("\t" + grid[row][column]);
}
System.out.println();
}
}
public static boolean isWithinGrid (int row, int col, String cmd, char[][] grid) {
return true;
}
public static void swap (int row, int col, String cmd, char[][] grid){
}
public static boolean updateGrid (char[][] grid, char[] options) {
return false;
}
}
'