Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How to do write question and answer class? The main method is text file. Answer

ID: 3727697 • Letter: H

Question

How to do write question and answer class? The main method is text file. Answer -text: String -associatedoutcome Indices: ArrayList Quiz Question -questions: ArrayList -numofQuestionsAnswered: int -possibleOutcomes : ArrayList +getNextQuestion) Question +allQuestionsAnswered): boolean +calculateResult):String tquestion: String -answers: ArrayList selectedAnswer: int tgetQuestion: String +getAnswers): String +setSelectedAnswer (index:int) +getOutceIndicesorselectedAnswer(): ArrayList TextApp -quiz: Quiz +play ( GUIApp -quiz: Quiz +start(stage:PrimaryStage)

Explanation / Answer

import java.util.*;

//Answer class

class Answer

{

// define text

String text;

// define associated outcome indices with this answer

ArrayList<Integer> associatedOutcomeIndices;

}

//Question class

class Question

{

//define question text

String question;

//define its answers

ArrayList<Answer> answers;

//define its selected answer index

int selectedAnswer;

  

//default constructor

public Question()

{

  

}

//get question text

public String getQuestion()

{

return this.question;

}

//get answers array associated with this question

public String[] getAnswers()

{

int n = answers.size(); //get size of the answers array

String[] answers_array = new String[n]; //create a new string array

for(int i=0;i<n;i++) //iterate over each answer in answers arraylist

{

answers_array[i] = answers.get(i).text; //fill indices of answers_array with each answers text

}

return answers_array; //return this answers_array

}

//set selected answer index

public void setSelectedAnswer(int index)

{

this.selectedAnswer = index;

}

//get outcome indices of selected answer

public ArrayList<Integer> getOutcomeIndicesOfSelectedAnswer()

{

//first get the selected answer Answer object and then get its associatedOutcomeIndices

return this.answers.get(this.selectedAnswer).associatedOutcomeIndices;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote