diff --git a/src/main/java/Game/ChessObj/ChessBoard.java b/src/main/java/Game/ChessObj/ChessBoard.java index 4a6abef..0b327c7 100644 --- a/src/main/java/Game/ChessObj/ChessBoard.java +++ b/src/main/java/Game/ChessObj/ChessBoard.java @@ -13,14 +13,14 @@ public class ChessBoard { ChessFigure.Type[] order = { ChessFigure.Type.CASTLE, ChessFigure.Type.KNIGHT, ChessFigure.Type.BISHOP, ChessFigure.Type.QUEEN, ChessFigure.Type.KING, ChessFigure.Type.BISHOP, ChessFigure.Type.KNIGHT, ChessFigure.Type.CASTLE }; - for (int i = 0; i < board.length; i++) { + for (int x = 0; x < board[0].length; x++) { //sets all pawns - board[i][1] = new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.BLACK); - board[i][6] = new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.WHITE); + board[1][x] = new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.BLACK); + board[6][x] = new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.WHITE); //sets all others - board[i][0] = new ChessFigure(order[i], ChessFigure.Team.BLACK); - board[i][7] = new ChessFigure(order[i], ChessFigure.Team.WHITE); + board[0][x] = new ChessFigure(order[x], ChessFigure.Team.BLACK); + board[7][x] = new ChessFigure(order[x], ChessFigure.Team.WHITE); } } diff --git a/src/test/java/Game/ChessObj/ChessBoardTest.java b/src/test/java/Game/ChessObj/ChessBoardTest.java index ca744d5..8c90997 100644 --- a/src/test/java/Game/ChessObj/ChessBoardTest.java +++ b/src/test/java/Game/ChessObj/ChessBoardTest.java @@ -26,28 +26,28 @@ class ChessBoardTest { @Test void initBoard() { ChessFigure[][] board = chessBoard.getBoard(); - for (int x = 0; x < board.length; x++) { - for (int y = 0; y < board[0].length; y++) { + for (int x = 0; x < board[0].length; x++) { + for (int y = 0; y < board.length; y++) { //test pawns if (y == 1) { - assertEquals(new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.BLACK), board[x][y]); + assertEquals(new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.BLACK), board[y][x]); continue; } if(y == 6) { - assertEquals(new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.WHITE), board[x][y]); + assertEquals(new ChessFigure(ChessFigure.Type.PAWN, ChessFigure.Team.WHITE), board[y][x]); continue; } if(y == 0){ - assertEquals(new ChessFigure(startOrder[x], ChessFigure.Team.BLACK), board[x][y]); + assertEquals(new ChessFigure(startOrder[x], ChessFigure.Team.BLACK), board[y][x]); continue; } if(y == 7){ - assertEquals(new ChessFigure(startOrder[x], ChessFigure.Team.WHITE), board[x][y]); + assertEquals(new ChessFigure(startOrder[x], ChessFigure.Team.WHITE), board[y][x]); continue; } //rest should be empty(null) - assertNull(board[x][y]); + assertNull(board[y][x]); } } }