Package SolvishR
Class QuestionFactory
java.lang.Object
SolvishR.QuestionFactory
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 Summary
Modifier and TypeMethodDescriptionbuildQuestion(int amount, String type) Builds a list of questions of a specific type.static QuestionFactoryGets the singleton instance of the SolvishR.QuestionFactory.getQuestion(String questionType) Gets a specific type of question based on the provided question type.Interactively gets user preferences for question types and quantity.
-
Method Details
-
getInstance
Gets the singleton instance of the SolvishR.QuestionFactory.- Returns:
- The singleton instance of the SolvishR.QuestionFactory.
-
getQuestion
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
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
Interactively gets user preferences for question types and quantity.- Returns:
- A list of questions based on the user's preferences.
-