From acb204f551ba2f5d58169e2260aadb440b8b7ec0 Mon Sep 17 00:00:00 2001 From: Andrin Fassbind Date: Sat, 9 Oct 2021 15:44:36 +0200 Subject: [PATCH] set variable player1 & player2 to final deleted unnecessary import in Test classes added outputTieText to class Game --- .idea/runConfigurations.xml | 10 ++++++++++ gruppe06-hufflepuff-projekt1-tic-tac-toe.iml | 16 ++++++++++++++++ src/Game.java | 5 +++-- src/Language.java | 2 +- test/GameTest.java | 5 +++-- test/GamefieldTest.java | 2 +- 6 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 .idea/runConfigurations.xml diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/gruppe06-hufflepuff-projekt1-tic-tac-toe.iml b/gruppe06-hufflepuff-projekt1-tic-tac-toe.iml index c5e5271..8d22ed4 100644 --- a/gruppe06-hufflepuff-projekt1-tic-tac-toe.iml +++ b/gruppe06-hufflepuff-projekt1-tic-tac-toe.iml @@ -60,5 +60,21 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Game.java b/src/Game.java index 6718540..f61e715 100644 --- a/src/Game.java +++ b/src/Game.java @@ -11,8 +11,8 @@ public class Game { private Gamefield gamefield; private Language language; - private int player1 = 1; - private int player2 = 2; + private final int player1 = 1; + private final int player2 = 2; private int playerPlaying = 1; // @@ -52,6 +52,7 @@ public class Game { language.outputWinnerText(playerPlaying); gameFinished = true; } else if (checkForTie()) { + language.outputTieText(); language.outputGameOverText(); gameFinished = true; } diff --git a/src/Language.java b/src/Language.java index a67b607..abd416b 100644 --- a/src/Language.java +++ b/src/Language.java @@ -63,7 +63,7 @@ public class Language { /** * Methode: outputMove - * Diese Methode gibt die Anzahl Spielzüge aus, die im Spiel bereits gemacht worden sind, und + * Diese Methode gibt die Anzahl Spielzüge aus, die im Spiel bereits gemacht worden sind und * welcher Spieler den Zug macht */ public void outputMoveText(int move, int player) { diff --git a/test/GameTest.java b/test/GameTest.java index 06b61e5..ca7c122 100644 --- a/test/GameTest.java +++ b/test/GameTest.java @@ -1,4 +1,3 @@ -import org.junit.Assert; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -6,6 +5,8 @@ import org.junit.jupiter.api.Test; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Klasse GameTest * @@ -67,7 +68,7 @@ class GameTest { System.out.println("Hello Baeldung Readers!!"); System.out.println("Hello Baeldung Readers!!"); - Assert.assertEquals("Hello Baeldung Readers!!\n" + + assertEquals("Hello Baeldung Readers!!\n" + "Hello Baeldung Readers!!\n" + "Hello Baeldung Readers!!\n" + "Hello Baeldung Readers!!", outputStreamCaptor.toString() diff --git a/test/GamefieldTest.java b/test/GamefieldTest.java index 0899170..ea1858d 100644 --- a/test/GamefieldTest.java +++ b/test/GamefieldTest.java @@ -1,4 +1,3 @@ -import org.junit.Before; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; @@ -32,5 +31,6 @@ class GamefieldTest { @Test void outputField() { + gamefield.outputField(); } } \ No newline at end of file