package org.example; import java.util.Scanner; public class Game { private static final Scanner scanner = new Scanner(System.in); public static void main(String... args) { loop( new Player("Sam"), new Player("Daniel") ); } private static void loop(Player... players) { while (true) { for (Player player : players) { System.out.println("\n" + "===================================\n" + "Next player: " + player.getName()); player.rollTheDices(); System.out.println(player); interactWith(player); } } } private static void interactWith(Player player) { while (true) { System.out.println("" + "[r] roll the dices\n" + "[i] mark dice i\n" + "[f] finish round"); String line = scanner.nextLine(); switch (line) { case "r": player.rollTheDices(); System.out.println(player); break; case "f": player.finishRound(); System.out.println(player); return; default: int i = Integer.parseInt(line); player.toggleMark(i); System.out.println(player); break; } } } }