Question: Basic java please help QUESTION 1: Add code to ask user about the number of players (from 1 to 3) – use game.askForInt. Store the input in a variable numPlayers. QUESTION 2: Modify the code


Question: Basic java please help  QUESTION 1: Add code to ask user about the number of players (from 1 to 3) – use game.askForInt. Store the input in a variable numPlayers. QUESTION 2: Modify the code below to ask for players’ names and add them to the game in a for loop (up to numPlayers iterations). String name = game.askForText(“What is player 0

This problem has been solved!

Basic java please help 

QUESTION 1: Add code to ask user about the number of players (from 1 to 3) – use game.askForInt. Store the input in a variable numPlayers.

QUESTION 2: Modify the code below to ask for players’ names and add them to the game in a for loop (up to numPlayers iterations).

String name = game.askForText(“What is player 0 name?”);

game.addPlayer(name);

name = game.askForText(“What is player 1 name?”);

game.addPlayer(name);

name = game.askForText(“What is player 2 name?”);

game.addPlayer(name);

QUESTION 3: Modify this part to ask questions and get answers in a for loop (up to numPlayers iterations)  

game.setCurrentPlayer(0);

String answer = game.askForText(q0);

if(a0.equals(answer))

game.correct(); //display “Correct”, increment score, change frame color to green

else

game.incorrect(); //display “incorrect”, change frame color of player to red

game.setCurrentPlayer(1);

answer = game.askForText(q1);

if(a1.equals(answer))

game.correct();

else

game.incorrect();

game.setCurrentPlayer(2);

answer = game.askForText(q2);

if(a2.equals(answer))

game.correct();

else

game.incorrect();