title: How do you use an array to store questions and answers inside to make a quiz
body: <p>I am working on an assignement based in a chapter about arrays in my Java textbook that says:</p>
  
  <blockquote>
    <p>Use the Question class from Chapter 5 to define a Quiz class. A quiz can be composed of up to 25 questions. Define the add method of the Quiz class to add a question to a quiz. Define the giveQuiz method of the Quiz class to add a question to a quiz. Define the giveQuiz method of the Quiz class to present each question in turn to the user, accept an answer for each one, and keep track of the results. Define a class called QuizTime with a main method that chooses questions for a quiz, presents the quiz to the user, collects and checks the answers, and prints the final results.</p>
  </blockquote>
  
  <p>The program development plan for this assignment that I am thinking about that may or not be correct is here:</p>
  
  <blockquote>
    <blockquote>
      <ol>
      <li><p>Create Quiz class</p></li>
      <li><p>create add method in Quiz class to add a question to a quiz</p></li>
      <li><p>Define giveQuiz method in Quiz class to give question to user</p></li>
      <li><p>make it accept answer for each question,</p></li>
      </ol>
      
      <p>5.Keep track of results of answers</p>
      
      <p>6.Create another class called QuizTime</p>
      
      <ol start="7">
      <li>Create a main method.</li>
      </ol>
      
      <p>8.Make method that allows questions to be inputted as an array into parameters of method</p>
      
      <p>9.store and check answers</p>
      
      <ol start="10">
      <li>print results.</li>
      </ol>
    </blockquote>
  </blockquote>
  
  <p>It seems to me like It is asking to make a total of 3 classes and one main method.</p>
  
  <p>However, I feel confused for why there needs to be so many classes. The methods in the Question class that is given below seem to have methods that do what the assignment tells the programmer to do but the methods look empty and have no use. I am also confused on my program dev plan from #6-10. I am not sure how I would make an array to store questions and answers into a method.</p>
  
  <p>Here is the Question class that is given already in the Java textbook:</p>
  
  <pre><code>    //********************************************************************
      //  Question.java       Author: Lewis/Loftus/Cocking
      //
      //  Represents a question (and its answer).
      //********************************************************************
  
      public class Question implements Complexity
      {
         private String question, answer;
         private int complexityLevel;
  
         //-----------------------------------------------------------------
         //  Sets up the question with a default complexity.
         //-----------------------------------------------------------------
         public Question (String query, String result)
         {
            question = query;
            answer = result;
            complexityLevel = 1;
         }
  
         //-----------------------------------------------------------------
         //  Sets the complexity level for this question.
         //-----------------------------------------------------------------
         public void setComplexity (int level)
         {
            complexityLevel = level;
         }
  
         //-----------------------------------------------------------------
         //  Returns the complexity level for this question.
         //-----------------------------------------------------------------
         public int getComplexity()
         {
            return complexityLevel;
         }
  
         //-----------------------------------------------------------------
         //  Returns the question.
         //-----------------------------------------------------------------
         public String getQuestion()
         {
            return question;
         }
         //-----------------------------------------------------------------
         //  Returns the answer to this question.
         //-----------------------------------------------------------------
         public String getAnswer()
         {
            return answer;
         }
  
         //-----------------------------------------------------------------
         //  Returns true if the candidate answer matches the answer.
         //-----------------------------------------------------------------
         public boolean answerCorrect (String candidateAnswer)
         {
            return answer.equals(candidateAnswer);
         }
  
         //-----------------------------------------------------------------
         //  Returns this question (and its answer) as a string.
         //-----------------------------------------------------------------
         public String toString()
         {
            return question + "\n" + answer;
         }
      }
  </code></pre>
  
  <blockquote>
    <p>Here is the quiz class that I created in which I haven't worked on
    much.</p>
  </blockquote>
  
  <pre><code>public class Quiz
  {
      private String add;
  
      public String addQuest (String addQ)//adds questions to quiz
      {
          add = addQ;
          return add;//returninng the question
      }
  
      public String giveQuiz ()//give the quiz to the user
      {
          //accept and store each answer
          return;
      }
  }
  </code></pre>
  
  <p>QuizTime class:</p>
  
  <pre><code>public class QuizTime
  {
      private String question; 
  
      public String[] Quiz() {
      }
      public String toString(String quest)
      {
          question = quest;
          for (int i = 0; i &lt; 25; i++)
              Quiz[i] = new Quiz (question);
      }
  
      public String presents ()
      {
          for (int i = 0; i &lt; 25; i++)
              return quest[i];
      }
  }
  </code></pre>
  
  <p>I haven't made the main method yet because I still don't know how the development of these classes are going to work. I apologize for my low skill in classes and arrays for I just learned them. I thank you guys so much for your help in advance.</p>
  
  <p>For the Quiz class, in the first method I am trying to have the main method insert parameters for questions that could be stored inside the method. But I want to know if there is an easier way to store 25 parameters of quiz questions inside of the method if that is even possible. I am trying Please let me know if I am or not on the right track. Thank you very much.</p>