Use enhanced switch form Java 17, Remove unused method
This commit is contained in:
parent
4c49f939ee
commit
2cfa7130fc
@ -53,10 +53,6 @@ public class TicTacToeGame {
|
|||||||
return this.state != GameState.RUNNING;
|
return this.state != GameState.RUNNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setState(GameState state) {
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameState getState() {
|
public GameState getState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@ -69,12 +65,8 @@ public class TicTacToeGame {
|
|||||||
interestingStates.add(this.cells[winningCombination[2]]);
|
interestingStates.add(this.cells[winningCombination[2]]);
|
||||||
if (interestingStates.size() == 1 && !interestingStates.contains(CellState.EMPTY)) {
|
if (interestingStates.size() == 1 && !interestingStates.contains(CellState.EMPTY)) {
|
||||||
switch (this.cells[winningCombination[0]]) {
|
switch (this.cells[winningCombination[0]]) {
|
||||||
case O:
|
case O -> this.state = GameState.O_WON;
|
||||||
this.state = GameState.O_WON;
|
case X -> this.state = GameState.X_WON;
|
||||||
break;
|
|
||||||
case X:
|
|
||||||
this.state = GameState.X_WON;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -66,12 +66,8 @@ public class UltimateTicTacToe {
|
|||||||
interestingStates.add(this.masterGameStates[winningCombination[2]]);
|
interestingStates.add(this.masterGameStates[winningCombination[2]]);
|
||||||
if (interestingStates.size() == 1 && !interestingStates.contains(GameState.RUNNING)) {
|
if (interestingStates.size() == 1 && !interestingStates.contains(GameState.RUNNING)) {
|
||||||
switch (this.masterGameStates[winningCombination[0]]) {
|
switch (this.masterGameStates[winningCombination[0]]) {
|
||||||
case O_WON:
|
case O_WON -> this.gameState = GameState.O_WON;
|
||||||
this.gameState = GameState.O_WON;
|
case X_WON -> this.gameState = GameState.X_WON;
|
||||||
break;
|
|
||||||
case X_WON:
|
|
||||||
this.gameState = GameState.X_WON;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user