static void printDesc(char[][] desc) { int d = 0; System.out.print("y\\x"); for (int i = 0; i<desc.length; i++) System.out.print(" " + i + ":"); System.out.println(""); printDivider(desc.length); for (int i = 0; i < desc.length; i++) { System.out.print(d + ": | "); for (int j = 0; j < desc.length; j++) { System.out.print(desc[j][i]); System.out.print(" | "); } System.out.println(); printDivider(desc.length); d++; } } static void printDivider(int length) { System.out.print(" "); for (int i = 0; i<length-1;i++) { System.out.print("----"); } System.out.println("---"); }
for the test:
char[][] d = new char[][] {{'x','x','x','x','x'}, {'x','x','x','x','x'}, {'x','x','x','x','x'}, {'x','x','x','x','x'}, {'x','x','x','x','x'}};
Result:
y\x 0: 1: 2: 3: 4: ------------------- 0: | x | x | x | x | x | ------------------- 1: | x | x | x | x | x | ------------------- 2: | x | x | x | x | x | ------------------- 3: | x | x | x | x | x | ------------------- 4: | x | x | x | x | x | -------------------
for the test:
char[][] d = new char[][] {{'x','x'}, {'x','x'}};
Result:
y\x 0: 1: ------- 0: | x | x | ------- 1: | x | x | -------
System.out.println("y\\x 0: 1: 2:");fixed right in the codeSystem.out.println("y\\x 0: 1: 2:");andSystem.out.println(" -----------");. These 2 lines do not depend on the size of your field. they will not stretch. - Mikhail Vaysman