From 2cfa7130fc5b2eb559c77faee3e7bf7559135369 Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Wed, 3 Nov 2021 23:20:04 +0100 Subject: [PATCH] Use enhanced switch form Java 17, Remove unused method --- .../ultimatetictactoe/model/TicTacToeGame.java | 12 ++---------- .../ultimatetictactoe/model/UltimateTicTacToe.java | 8 ++------ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/main/java/de/icaotix/ultimatetictactoe/model/TicTacToeGame.java b/src/main/java/de/icaotix/ultimatetictactoe/model/TicTacToeGame.java index c708805..6ccff98 100644 --- a/src/main/java/de/icaotix/ultimatetictactoe/model/TicTacToeGame.java +++ b/src/main/java/de/icaotix/ultimatetictactoe/model/TicTacToeGame.java @@ -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; } diff --git a/src/main/java/de/icaotix/ultimatetictactoe/model/UltimateTicTacToe.java b/src/main/java/de/icaotix/ultimatetictactoe/model/UltimateTicTacToe.java index 0862d6c..ee67b77 100644 --- a/src/main/java/de/icaotix/ultimatetictactoe/model/UltimateTicTacToe.java +++ b/src/main/java/de/icaotix/ultimatetictactoe/model/UltimateTicTacToe.java @@ -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; }