Please help me with this basic computer science question Pub
Please help me with this basic computer science question
Public class Main {static Game game; public static void main(String[] args) {String ans; do{//This is the beginning of the game loop//Reset the game game = new Game();//REQ1: Modify the code below to replace these 6 variables with two String arrays: questions, and answers, each having 3 elements, e.g. questions[0] replaces q0, answers[0] replaces a0, etc. String q0 = \"question0\"; String a0 = \"answer0\"; String q1 = \"question1\"; String a1 = \"answer1\"; String q2 = \"question2\"; String a2 = \"answer2\";//END of REQ1//REQ2: Add code to ask user about the number of players (from 1 to 3) - use game.askForInt. Store the input in a variable numPlayers.//REQ3: 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);//END of REQ3//REQ4: 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();//END of REQ4//Do you want to play again? make sure you get valid input ans = game.askForText(\"Play again? (Y/N)\"); while(ans != null && !ans.toUpperCase().equals(\"Y\") && !ans.toUpperCase().equals(\"N\")) ans = game.askForText(\"Invalid input. Play again? (Y/N)\");}while(ans.toUpperCase().equals(\"Y\"));//play again if the user answers \"Y\" or \"y\" System.exit(1);//This statement terminates the programSolution
Public class main // main class declaration
{
Static Game game;//assiging the static class, were it cannot be called anywere
public static void main(string[] , arg);
{
string ans; // assigning the variable
do{ // starting of the game
//resetting of the game
game = new game();
String q0 = Questions[10][10][10] //array is introduced for the question and variable is declared
String a0 = Answers[10][10][10] // variable for the answer is declared in form of array.
while(number!= guess) //guessing the number of players
game.addplayer(&player_input);
askfortext(\"Its player\'s\" turn, player_num);
while(player_number != player_input) checking the condition were the entered input is valid or not.
}
if(Player_1 != Player_num) // if the entered text is not valid then we have to wait for the turn
player_2 = player_num // second player will be getting the chance.
}
rest all not clear to proceed further , which are more blurr and very tiny to read. Please give us the clear picture to proceed further
![Please help me with this basic computer science question Public class Main {static Game game; public static void main(String[] args) {String ans; do{//This is t Please help me with this basic computer science question Public class Main {static Game game; public static void main(String[] args) {String ans; do{//This is t](/WebImages/23/please-help-me-with-this-basic-computer-science-question-pub-1055141-1761550372-0.webp)
![Please help me with this basic computer science question Public class Main {static Game game; public static void main(String[] args) {String ans; do{//This is t Please help me with this basic computer science question Public class Main {static Game game; public static void main(String[] args) {String ans; do{//This is t](/WebImages/23/please-help-me-with-this-basic-computer-science-question-pub-1055141-1761550372-1.webp)