Olá pessoal, sou nova nessa área e meu professor da faculdade pediu para desenvolver um jogo de caça ao Tesouro (parecido com batalha naval) onde, precisa ser de 2 a 4 players, e eles precisam ser maiores de 12 anos. O problema é, já coletei os dados do usuário, porém não sei como sair da parte da validação e fazer o loop. O tabuleiro já está pronto, mas meu código está todo bagunçado =(
Pode ser uma pergunta meio estúpida mas eu travei nessa parte. Me ajudem, por favor!
public static void main(String[] args) {
String namePlayer;
int numPlayers;
// ArrayList<String> players = new ArrayList();
// ArrayList<Integer> scores = new ArrayList();
System.out.println("Welcome to the Pirate Peter's Treasure Hunt Game, are you ready for this adventure? ");
Scanner sc = new Scanner(System.in); //take the information from the user
for(int counter=0;counter<4;counter++){
System.out.println("Please enter the number of players between 2 and 4"); //show the instructions
numPlayers = sc.nextInt();
if((numPlayers == 2) || (numPlayers == 3) || (numPlayers == 4)){ //check if the number of players are between 2 and 4
System.out.println("ARGH! What's the name of the Pirate? ");
namePlayer = sc.nextLine();
}
else {
System.out.println("OH God! This number of players are not right! Enter a number between 2 and 4: ");
numPlayers = sc.nextInt();
}