title: Main method doesn't run program in spite of all tests passing
body: <p>I am making a quiz application in Java and am using JUnit to test my methods. Right now, my src folder has one main folder. The main folder further has two packages, model and UI. The model package contains one class called QuizQuestions and contains the modeling of data. The UI package has 2 classes, Quiz and Main. Quiz class provides print statements to the QuizQuestions class and the Main class has the Main method. Here is the code:</p>
  <p>QuizQuestions class (model):</p>
  <pre><code>package model;
  
  import ui.Quiz;
  
  import java.util.*;
  
  public class QuizQuestions {
  
      Map&lt;String, String&gt; questionsAndAnswers;
      Quiz quiz;
  
      // REQUIRES: the map data structure, specifically the field named questionsAndAnswers
      // MODIFIES: nothing
      // EFFECTS: creates a new linked hashmap by the name questionsAndAnswers
      public QuizQuestions() {
          questionsAndAnswers = new LinkedHashMap&lt;&gt;();
      }
  
      // REQUIRES: nothing
      // MODIFIES: this
      // EFFECTS: adds the questions and answers to the linked list in an ordered format
      public LinkedHashMap&lt;String, String&gt; entireQuestionsList() {
          questionsAndAnswers.put(&quot;Purpose of spinning jenny in the Industrial Revolution &quot;,
                  &quot;\na)A device for making cloth\nb)A device for storing energy\nc)A steam engine\nd)A water pump\n\n&quot;);
          questionsAndAnswers.put(&quot;A city NOT founded by the Romans &quot;, &quot;\na)Alexandria\nb)Berlin\nc)London\nd)None\n\n&quot;);
          questionsAndAnswers.put(&quot;Number of wives Henry VIII had &quot;, &quot;\na)1\nb)6\nc)3\nd)2\n&quot;);
          questionsAndAnswers.put(&quot;Country of origin of Zoroastrianism &quot;, &quot;\na)Brazil\nb)Egypt\nc)Persia\nd)India\n\n&quot;);
          questionsAndAnswers.put(&quot;The person who captured Moscow for the last time in history &quot;,
                  &quot;\na)No one\nb)Hitler\nc)Napoleon\nd)Ogedei Khan\n\n&quot;);
          questionsAndAnswers.put(&quot;First time the Winter Olympics were held in &quot;,
                  &quot;\na)1896\nb)1900\nc)1888\nd)1924\n\n&quot;);
          questionsAndAnswers.put(&quot;Number of chapters in the Olympic Charter &quot;, &quot;\na)5\nb)6\nc)7\nd)8\n\n&quot;);
          questionsAndAnswers.put(&quot;Designer of the trophy of FIFA Women’s World Cup? &quot;,
                  &quot;\na)William Sawaya\nb)Formiga\nc)Marta\nd)Sun Wen\n\n&quot;);
          questionsAndAnswers.put(&quot;The Mission Hills World Cup is related to &quot;, &quot;\na)Golf\nb)Polo\nc)TT\nd)Chess\n\n&quot;);
          questionsAndAnswers.put(&quot;Number of players who have reached the 100-goal mark in EPL &quot;,
                  &quot;\na)5\nb)10\nc)28\nd)30\n\n&quot;);
          questionsAndAnswers.put(&quot;Location of the Spanish Steps &quot;, &quot;\na)Rome\nb)Lisbon\nc)Madrid\nd)Barcelona\n\n&quot;);
          questionsAndAnswers.put(&quot;Total number of provinces in Canada &quot;, &quot;\na)5\nb)10\nc)30\nd)20\n\n&quot;);
          questionsAndAnswers.put(&quot;A popular Middle Eastern dish &quot;, &quot;\na)Pasta\nb)Dolma\nc)Pizza\nd)Curry\n\n&quot;);
          questionsAndAnswers.put(&quot;Location of the Chocolate Hills &quot;,
                  &quot;\na)Pakistan\nb)Japan\nc)Philippines\nd)India\n\n&quot;);
          questionsAndAnswers.put(&quot;The tallest building amongst the following is &quot;,
                  &quot;\na)The Shard\nb)Burj Khalifa\nc)Skytree\nd)Moscow Tower\n\n&quot;);
          return (LinkedHashMap&lt;String, String&gt;) questionsAndAnswers;
      }
  
      // REQUIRES: questionsAndAnswers linked list should not be empty
      // MODIFIES: nothing
      // EFFECTS: gets the questions and answers from the linked list
      // and displays one question and its corresponding answers one after
      // the other while providing the user the option to enter his/her answer
      // for each question.
      public ArrayList&lt;String&gt; askQuestionsOneByOne() {
          quiz = new Quiz();
          Set&lt;Map.Entry&lt;String, String&gt;&gt; entry = questionsAndAnswers.entrySet();
          ArrayList&lt;String&gt; userAnswer = new ArrayList&lt;&gt;();
          for (Object o : entry) {
              System.out.println(o);
              String answer = quiz.askUser();
              userAnswer.add(answer);
          }
          return userAnswer;
      }
  
      // REQUIRES: nothing
      // MODIFIES: this
      // EFFECTS: adds the correct answers of all the questions to
      // a linked list and returns that list.
      public ArrayList&lt;String&gt; storeCorrectAnswers() {
          ArrayList&lt;String&gt; correctAnswers = new ArrayList&lt;&gt;();
          correctAnswers.add(&quot;a&quot;);
          correctAnswers.add(&quot;a&quot;);
          correctAnswers.add(&quot;b&quot;);
          correctAnswers.add(&quot;c&quot;);
          correctAnswers.add(&quot;c&quot;);
          correctAnswers.add(&quot;d&quot;);
          correctAnswers.add(&quot;b&quot;);
          correctAnswers.add(&quot;a&quot;);
          correctAnswers.add(&quot;a&quot;);
          correctAnswers.add(&quot;d&quot;);
          correctAnswers.add(&quot;a&quot;);
          correctAnswers.add(&quot;b&quot;);
          correctAnswers.add(&quot;b&quot;);
          correctAnswers.add(&quot;c&quot;);
          correctAnswers.add(&quot;b&quot;);
          return correctAnswers;
      }
  
      // REQUIRES: storeCorrectAnswers and askQuestionsOneByOne is not empty
      // MODIFIES: nothing
      // EFFECTS: stores the answers obtained from storeCorrectAnswers and
      // askQuestionsOneByOne into 2 new linked lists and compares both of
      // them. Whenever the answer at a particular index in both the lists
      // is the same, the score of the user is incremented by 1 and the
      // total score is returned at the end of the method.
      public int compareAnswers() {
          ArrayList&lt;String&gt; userAnswers = storeCorrectAnswers();
          ArrayList&lt;String&gt; correctAnswers = askQuestionsOneByOne();
          int score = 0;
          for (int i = 0; i &lt; userAnswers.size(); i++) {
              if (userAnswers.get(i).equals(correctAnswers.get(i))) {
                  score++;
              }
          }
          return score;
      }
  
      // REQUIRES: the value of the score variable from compareAnswers()
      // MODIFIES: nothing
      // EFFECTS: displays the score of the user and according to the score,
      // displays a message informing the user about how good the score is.
      public void displayScoreAndPerformanceMessage() {
          quiz = new Quiz();
          int score = compareAnswers();
          quiz.printScore();
          if (score &lt; 5 &amp;&amp; score &gt; 0) {
              quiz.messageForScoreLessThanFive();
              askUserToPlayAgain();
          } else if (score &gt;= 5 &amp;&amp; score &lt; 10) {
              quiz.messageForScoreMoreThanFiveAndLessThanTen();
              askUserToPlayAgain();
          } else if (score &gt;= 10 &amp;&amp; score != 15) {
              quiz.messageGorScoreMoreThanTenAndLessThanFifteen();
              askUserToPlayAgain();
          } else {
              quiz.messageForPerfectScore();
          }
      }
  
      // REQUIRES: the list of quiz questions and the user score
      // MODIFIES: converts the user answer to lower case if he/she enters
      // the response in uppercase.
      // EFFECTS: gives the user the option to play the quiz again
      // and based on the answer, starts the quiz from scratch or exits the program
      public void askUserToPlayAgain() {
          quiz = new Quiz();
          String response = quiz.askUserForPlayingAgain();
          while (response.equalsIgnoreCase(&quot;y&quot;)) {
              entireQuestionsList();
              displayScoreAndPerformanceMessage();
              askUserToPlayAgain();
          }
          if (response.equalsIgnoreCase(&quot;n&quot;)) {
              quiz.thankYouMessage();
              System.exit(1);
          } else {
              quiz.errorMessage();
              askUserToPlayAgain();
          }
      }
  }
  </code></pre>
  <p>Quiz class (UI):</p>
  <pre><code>package ui;
  
  import model.QuizQuestions;
  
  import java.util.Scanner;
  
  public class Quiz {
  
      Quiz qz;
  
      public Quiz() {
          qz = new Quiz();
      }
  
      public void displayGreeting() {
          System.out.println(&quot;Welcome to the quiz application!\n\nHere are the quiz questions.&quot;);
      }
  
      // REQUIRES: nothing
      // MODIFIES: nothing
      // EFFECTS: allows the user to enter their answer for
      // each question and returns that answer.
      public String askUser() {
          Scanner sc = new Scanner(System.in);
          return sc.next();
      }
  
      // REQUIRES: score from the compareAnswers method in QuizQuestions
      // MODIFIES: nothing
      // EFFECTS: displays the score of the user on the screen
      public void printScore() {
          QuizQuestions qq = new QuizQuestions();
          int score = qq.compareAnswers();
          System.out.println(&quot;Your score is &quot; + score);
      }
  
      // EFFECTS: displays a particular message if the user score is less than 5
      public void messageForScoreLessThanFive() {
          System.out.println(&quot;Looks like your general knowledge is weak. Try to read books!&quot;);
      }
  
      // EFFECTS: displays a particular message if the user score is more than 5
      // but less than 10.
      public void messageForScoreMoreThanFiveAndLessThanTen() {
          System.out.println(&quot;You are doing good! There is still potential to improve though!&quot;);
      }
  
      // EFFECTS: displays a particular message if the user score is more than 10
      // but less than 15.
      public void messageGorScoreMoreThanTenAndLessThanFifteen() {
          System.out.println(&quot;You are awesome! Your score is better than most of the people!&quot;);
      }
  
      // EFFECTS: displays a particular message if the user score is equal to 15.
      public void messageForPerfectScore() {
          System.out.println(&quot;Perfect score! Congratulations!&quot;);
      }
  
      // EFFECTS: asks the user whether he/she wants to play again and prompts them for a response.
      public String askUserForPlayingAgain() {
          System.out.println(&quot;Do you want to play the quiz again? (Y)es/(N)o?\n&quot;);
          Scanner scanner = new Scanner(System.in);
          return scanner.next();
      }
  
      // EFFECTS: displays a thank-you message at the end of the program.
      public void thankYouMessage() {
          System.out.println(&quot;Thanks for playing!\n&quot;);
      }
  
      // EFFECTS: displays an error message if the user does not select a right option
      public void errorMessage() {
          System.out.println(&quot;Please enter a valid response.\n&quot;);
      }
  
  }
  </code></pre>
  <p>Main method:</p>
  <pre><code>package ui;
  
  import model.QuizQuestions;
  
  public class Main {
      public static void main(String[] args) {
          QuizQuestions qq = new QuizQuestions();
          qq.entireQuestionsList();
          qq.askQuestionsOneByOne();
          qq.compareAnswers();
          qq.displayScoreAndPerformanceMessage();
          qq.askUserToPlayAgain();
      }
  }
  </code></pre>
  <p>All my tests are passing but when I try to run my program from the main method, it doesn't run. Where am I going wrong?</p>
  <p>Thank you</p>