From 97c66b727e5a7d26cf5676bcc4211b745b8b7ce0 Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Mon, 17 Jan 2022 18:58:33 +0100 Subject: [PATCH] 4gewinnt: refactored attributs and test methods --- src/main/java/de/tims/viergewinnt/ai/Logic.java | 6 +++--- src/test/java/de/tims/viergewinnt/ai/LogicTest.java | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/de/tims/viergewinnt/ai/Logic.java b/src/main/java/de/tims/viergewinnt/ai/Logic.java index 23a9a6b..1f643c8 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/src/main/java/de/tims/viergewinnt/ai/Logic.java @@ -13,9 +13,9 @@ import javax.swing.JPanel; public class Logic { - int[][] board = new int[6][6]; - int currentPlayer = 1; - int player1Score = 0; + private int[][] board = new int[6][6]; + private int currentPlayer = 1; + private int player1Score = 0; public void setField(int player, int row, int column) { board[row][column] = player; diff --git a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java index c9c2bb0..b70ad80 100644 --- a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java +++ b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java @@ -56,7 +56,7 @@ class LogicTest { testObj.setCurrentPlayer(player); testObj.playChip(column); - int realResult = testObj.currentPlayer; + int realResult = testObj.getCurrentPlayer(); assertEquals(expectedResult, realResult); } @@ -70,7 +70,7 @@ class LogicTest { testObj.setCurrentPlayer(player); testObj.playChip(column); - int realResult = testObj.currentPlayer; + int realResult = testObj.getCurrentPlayer(); assertEquals(expectedResult, realResult); } @@ -97,7 +97,7 @@ class LogicTest { testObj.setField(player, row, column); - assertEquals(1, testObj.board[row][column]); + assertEquals(1, testObj.getField(row, column)); } @Test @@ -108,7 +108,7 @@ class LogicTest { testObj.setField(player, row, column); - assertEquals(player, testObj.board[row][column]); + assertEquals(player, testObj.getField(row, column)); } @Test @@ -129,7 +129,7 @@ class LogicTest { testObj.setCurrentPlayer(player); - assertEquals(player, testObj.currentPlayer); + assertEquals(player, testObj.getCurrentPlayer()); } @Test @@ -147,7 +147,7 @@ class LogicTest { int expectedResult = 500; testObj.setPlayer1Score(expectedResult); - assertEquals(expectedResult, testObj.player1Score); + assertEquals(expectedResult, testObj.getPlayer1Score()); } @Test