Chess

Run Settings
LanguageJava
Language Version
Run Command
import java.util.ArrayList; class Main { public static void main(String[] args) { char[] litArr = {'a', 'b', 'c', 'd', 'e', 'f', 'j', 'h'}; String[][] chessDesk = new String[8][8]; for (int i = 0; i < chessDesk.length; i++) { for (int j = 0; j < chessDesk[i].length; j++) chessDesk[i][j] = litArr[i] + String.valueOf(j + 1); } for (int i = 0; i < chessDesk.length; i++) { for (int j = 0; j < chessDesk[i].length; j++) System.out.printf("%s ", chessDesk[i][j]); System.out.println(); } int[] queenCoords = new int[2]; queenCoords[0] = 2; queenCoords[1] = 1; MyPair queen = new MyPair(chessDesk[queenCoords[0]][queenCoords[1]], queenCoords); ArrayList<MyPair> queenHit = new ArrayList<>(); for (int i = 0; queenCoords[0] < 8 || queenCoords[1] < 8; i++) { queen queenHit.add( new MyPair(chessDesk[queenCoords[0] + i][queenCoords[1] + i], new int[]{queenCoords[0] + i, queenCoords[1] + i}) ); } } private static class MyPair { String cage; int[] coords = new int[2]; public MyPair(String cage, int[] coords) { this.cage = cage; this.coords = coords; } } }
Editor Settings
Theme
Key bindings
Full width
Lines