From 9897836eecde598d1f9a208c1270f9f8530575d1 Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Fri, 14 Jan 2022 20:25:05 +0100 Subject: [PATCH] 4gewinnt: setter for Board with player 1 --- src/main/java/de/tims/viergewinnt/ai/Logic.java | 6 +++++- src/test/java/de/tims/viergewinnt/ai/LogicTest.java | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/tims/viergewinnt/ai/Logic.java b/src/main/java/de/tims/viergewinnt/ai/Logic.java index c42c5cc..1378bed 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/src/main/java/de/tims/viergewinnt/ai/Logic.java @@ -13,9 +13,13 @@ import javax.swing.JPanel; public class Logic { - int[][] board; + int[][] board = new int[6][6]; int currentPlayer; + public void setField(int player, int row, int column) { + board[row][column] = 1; + } + public int playChip(int[][] playfield, int column, int player) { //add board update diff --git a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java index d37645c..7a1c79e 100644 --- a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java +++ b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java @@ -77,6 +77,17 @@ class LogicTest { assertEquals(expectedResult, realResult); } + @Test + void setFieldPlayer1Test() { + int player = 1; + int row = 0; + int column = 0; + + testObj.setField(player, row, column); + + assertEquals(1, testObj.board[row][column]); + } + private static Stream playfieldResults() { int[][] playfield1 = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0},