From bd09c5783b9bb3e2eaef1c80ab3d75b94d0c70d9 Mon Sep 17 00:00:00 2001 From: Malte Schellhardt Date: Tue, 18 Jan 2022 16:31:40 +0100 Subject: [PATCH] 4gewinnt: finished board creation with individual size --- src/main/java/de/tims/viergewinnt/ai/Logic.java | 6 +++--- src/test/java/de/tims/viergewinnt/ai/LogicTest.java | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/tims/viergewinnt/ai/Logic.java b/src/main/java/de/tims/viergewinnt/ai/Logic.java index 6151905..85ec410 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/src/main/java/de/tims/viergewinnt/ai/Logic.java @@ -13,13 +13,13 @@ import javax.swing.JPanel; public class Logic { - private int[][] board = new int[6][6]; + private int[][] board; private int currentPlayer = 1; private int player1Score = 0; private int player2Score = 0; public Logic(int size) { - // TODO Auto-generated constructor stub + this.board = new int[size][size]; } public void setField(int player, int row, int column) { @@ -31,7 +31,7 @@ public class Logic { } public int getBoardSize() { - return 0; + return this.board.length; } public void setCurrentPlayer(int player) { diff --git a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java index ab61f07..1ac3970 100644 --- a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java +++ b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java @@ -173,7 +173,7 @@ class LogicTest { @MethodSource("boardSizeParameters") void getBoardSize(String testName, int size) { int expectedResult = size; - int realResult = testObj.getBoardSize(); + int realResult = new Logic(size).getBoardSize(); assertEquals(expectedResult, realResult); } @@ -269,7 +269,8 @@ class LogicTest { private static Stream boardSizeParameters() { return Stream.of( - Arguments.of("board with size 0", 0) + Arguments.of("board with size 0", 0), + Arguments.of("board with size 6", 6) ); }