Package SolvishR

Class ExamFactory

java.lang.Object
SolvishR.ExamFactory

public class ExamFactory extends Object
The SolvishR.ExamFactory class is responsible for creating instances of different types of exams. It follows the Singleton pattern to ensure only one instance is created. It provides methods to get a non-timed exam, a timed exam with a specified time limit, and interactively get user preferences for exam types and questions.
Version:
1.0
Author:
Adib Sakhawat
  • Method Details

    • getInstance

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

      public Exam getExam()
      Gets a non-timed exam with an empty list of questions.
      Returns:
      A non-timed exam.
    • getExam

      public Exam getExam(int timeLimit)
      Gets a timed exam with a specified time limit and an empty list of questions.
      Parameters:
      timeLimit - The time limit for the exam in minutes.
      Returns:
      A timed exam.
      Throws:
      IllegalArgumentException - If the time limit is not a positive integer.
    • getExamChoice

      public Exam getExamChoice()
      Interactively gets user preferences for exam types and questions, then creates and returns the corresponding exam.
      Returns:
      An exam based on user preferences.
      Throws:
      IllegalArgumentException - If the exam type is not recognized.