set variable player1 & player2 to final

deleted unnecessary import in Test classes
added outputTieText to class Game
This commit is contained in:
Andrin Fassbind 2021-10-09 15:44:36 +02:00
parent a7f7758eca
commit acb204f551
6 changed files with 34 additions and 6 deletions

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>

View File

@ -60,5 +60,21 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library" scope="TEST">
<library name="JUnit5.7.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter/5.7.0/junit-jupiter-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.7.0/junit-jupiter-api-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.7.0/junit-platform-commons-1.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-params/5.7.0/junit-jupiter-params-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.7.0/junit-jupiter-engine-5.7.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.7.0/junit-platform-engine-1.7.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>

View File

@ -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;
}

View File

@ -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) {

View File

@ -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()

View File

@ -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();
}
}