Package SolvishR

Class QuestionFactory

java.lang.Object
SolvishR.QuestionFactory

public class QuestionFactory extends Object
The SolvishR.QuestionFactory class is responsible for creating instances of different types of questions. It follows the Singleton pattern to ensure only one instance is created. It provides methods to generate specific types of questions, build a list of questions, and interactively get user preferences for question types and quantity.
Version:
1.0
Author:
Adib Sakhawat
  • Method Details

    • getInstance

      public static QuestionFactory getInstance()
      Gets the singleton instance of the SolvishR.QuestionFactory.
      Returns:
      The singleton instance of the SolvishR.QuestionFactory.
    • getQuestion

      public Question getQuestion(String questionType)
      Gets a specific type of question based on the provided question type.
      Parameters:
      questionType - The type of question to create ("addition", "subtraction", "multiplication", "division").
      Returns:
      An instance of the specified question type.
      Throws:
      IllegalArgumentException - If the question type is not recognized.
    • buildQuestion

      public List<Question> buildQuestion(int amount, String type)
      Builds a list of questions of a specific type.
      Parameters:
      amount - The number of questions to generate.
      type - The type of question to create ("addition", "subtraction", "multiplication", "division").
      Returns:
      A list of questions of the specified type.
    • getQuestionChoice

      public List<Question> getQuestionChoice()
      Interactively gets user preferences for question types and quantity.
      Returns:
      A list of questions based on the user's preferences.