I'm a newbie, and I wholeheartedly admit that this should not be this hard.
I have an ArrayList of objects representing Questions, Correct Answers, and 3 "Wrong" Answers.
I have created a method named printIndividualQuestionItem() that prints out these items for each question, but I am unable to figure out how to call it from the main program.
How can I call the printIndividualQuestionItem() method to be able to print out an individual question and the corresponding answers?
Thank you in advance for any help.
import java.util.*; public class Cpractice { public static void main(String[] args) { ArrayList<IndividualQuestionItem> bubba = new ArrayList<IndividualQuestionItem>(); bubba.add( new IndividualQuestionItem("a", "b", "c", "d", "e") ); bubba.add( new IndividualQuestionItem("2", "2", "2", "2", "2") ); for (int i=0; i<bubba.size(); i++) System.out.println((IndividualQuestionItem) bubba.get(i)); System.out.println("Finished"); } } class IndividualQuestionItem { private String Question = ""; private String CorrectAnswer = ""; private String WrongAnswerA = ""; private String WrongAnswerB = ""; private String WrongAnswerC = ""; // Constructor for the IndividualQuestionItem class. // It takes 5 temporary variables to initialize the question items. public IndividualQuestionItem(String a, String b, String c, String d, String e) { Question = a; CorrectAnswer = b; WrongAnswerA = c; WrongAnswerB = d; WrongAnswerC = e; } // Print out the for the IndividualQuestionItem class. // public void printIndividualQuestionItem(IndividualQuestionItem temp) public void printIndividualQuestionItem() { System.out.print(this.Question + " "); System.out.print(this.CorrectAnswer + " "); System.out.print(this.WrongAnswerA + " "); System.out.print(this.WrongAnswerB + " "); System.out.println(this.WrongAnswerC); System.out.println(); } }