Changed huge if condition chain to a boolean term. Unit tests are being executed correctly
This commit is contained in:
+5
-27
@@ -15,7 +15,6 @@ public class Game {
|
||||
private final int player2 = 2;
|
||||
private int playerPlaying = 1;
|
||||
|
||||
//
|
||||
private boolean gameFinished = false;
|
||||
|
||||
public Game() {
|
||||
@@ -57,7 +56,6 @@ public class Game {
|
||||
language.outputGameOverText();
|
||||
gameFinished = true;
|
||||
}
|
||||
|
||||
switchPlayer();
|
||||
}
|
||||
|
||||
@@ -89,33 +87,13 @@ public class Game {
|
||||
*
|
||||
* Diese Methode prüft ob das Spiel einen Gewinner hat
|
||||
* @return bei erkanntem Gewinner true sonst false
|
||||
*
|
||||
*/
|
||||
private boolean checkForWin() {
|
||||
if (checkWinVariants(1,4,7)) {
|
||||
return true;
|
||||
}
|
||||
else if (checkWinVariants(2,5,8)) {
|
||||
return true;
|
||||
}
|
||||
else if (checkWinVariants(3,6,9)) {
|
||||
return true;
|
||||
}
|
||||
else if (checkWinVariants(1,2,3)) {
|
||||
return true;
|
||||
}
|
||||
else if (checkWinVariants(4,5,6)) {
|
||||
return true;
|
||||
}
|
||||
else if (checkWinVariants(7,8,9)) {
|
||||
return true;
|
||||
}
|
||||
else if (checkWinVariants(1,5,9)) {
|
||||
return true;
|
||||
}
|
||||
else if (checkWinVariants(3,5,7)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return checkWinVariants(1,4,7) || checkWinVariants(2,5,8) ||
|
||||
checkWinVariants(3,6,9) || checkWinVariants(1,2,3) ||
|
||||
checkWinVariants(4,5,6) || checkWinVariants(7,8,9) ||
|
||||
checkWinVariants(1,5,9) || checkWinVariants(3,5,7);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+7
-7
@@ -20,17 +20,17 @@ public class TicTacToe {
|
||||
/**
|
||||
* ## Die Bedienung:
|
||||
*
|
||||
* Um diese innovative TicTacToe Edition spielen zu können,
|
||||
* müssen Sie folgende Befehle eingeben.
|
||||
*
|
||||
* Um das TicTacToe spielen zu können, müssen Sie folgende Befehle eingeben:
|
||||
* g.placeField( Hier das gewünschte Feld als Zahl )
|
||||
*
|
||||
* Um die Sprache im Spiel zu wechseln, geben Sie folgendes Befehl ein:
|
||||
* g.changeLanguage("de");
|
||||
*
|
||||
* Um ein neues Spiel starten zu können, initialisieren Sie eine
|
||||
* neue Klasse mit folgendem Befehl:
|
||||
* Game g = new Game();
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Game g1 = new Game();
|
||||
|
||||
g1.placeField(1);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user