Skip to content

Commit

Permalink
возврат экземпляра игры напрямую из switch без использования переменной
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeloie committed Jul 30, 2023
1 parent 9b6213e commit f7e1585
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions app/src/main/java/hexlet/code/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ public class Menu {
public static final int PRIME = 6;

public static Game chooseGame(int userEnteredNumber) {
Game returnedGame = switch (userEnteredNumber) {
return switch (userEnteredNumber) {
case (EVEN) -> new Even();
case (CALC) -> new Calc();
case (GCD) -> new GCD();
case (PROGRESSION) -> new Progression();
case (PRIME) -> new Prime();
default -> throw new RuntimeException("Unexpected value: " + userEnteredNumber);
};
return returnedGame;
}
}

0 comments on commit f7e1585

Please sign in to comment.