Use enhanced switch form Java 17, Remove unused method

This commit is contained in:
Marcel Schwarz 2021-11-03 23:20:04 +01:00
parent 4c49f939ee
commit 2cfa7130fc
2 changed files with 4 additions and 16 deletions

View File

@ -53,10 +53,6 @@ public class TicTacToeGame {
return this.state != GameState.RUNNING;
}
public void setState(GameState state) {
this.state = state;
}
public GameState getState() {
return state;
}
@ -69,12 +65,8 @@ public class TicTacToeGame {
interestingStates.add(this.cells[winningCombination[2]]);
if (interestingStates.size() == 1 && !interestingStates.contains(CellState.EMPTY)) {
switch (this.cells[winningCombination[0]]) {
case O:
this.state = GameState.O_WON;
break;
case X:
this.state = GameState.X_WON;
break;
case O -> this.state = GameState.O_WON;
case X -> this.state = GameState.X_WON;
}
return;
}

View File

@ -66,12 +66,8 @@ public class UltimateTicTacToe {
interestingStates.add(this.masterGameStates[winningCombination[2]]);
if (interestingStates.size() == 1 && !interestingStates.contains(GameState.RUNNING)) {
switch (this.masterGameStates[winningCombination[0]]) {
case O_WON:
this.gameState = GameState.O_WON;
break;
case X_WON:
this.gameState = GameState.X_WON;
break;
case O_WON -> this.gameState = GameState.O_WON;
case X_WON -> this.gameState = GameState.X_WON;
}
return;
}