quiero que se agreg como agregar jugador # 1 dependiendo de las cantidad que se pida for…
- User
quiero que se agreg como agregar jugador # 1 dependiendo de las cantidad que se pida for (int i = 0; i < numNuevosJugadores; i++) { System.out.print("\n Número de dorsal: "); int dorsal = scanner.nextInt(); scanner.nextLine(); System.out.print("Nombre del jugador: "); String nombreJugador = scanner.nextLine(); System.out.print("Ciudad del jugador: "); String ciudadJugador = scanner.nextLine(); System.out.print("Edad del jugador: "); int edad = scanner.nextInt(); scanner.nextLine();
codenuevosJugadores.add(new Jugador(dorsal, nombreJugador, ciudadJugador, edad)); } - Assistant
Para agregar los nuevos jugadores con un formato específico que incluya "jugador #1", "jugador #2", etc., puedes modificar el bucle
forque ya tienes. Lo que harás es agregar unSystem.out.printque muestre el número del jugador en cada iteración del ciclo. Aquí te muestro cómo hacerlo:java