Class QuizControllerBuilder
java.lang.Object
ai.tutor.cab302exceptionalhandlers.builders.ControllerBuilder<QuizController>
ai.tutor.cab302exceptionalhandlers.builders.QuizControllerBuilder
Builder for creating instances of
QuizController
.
This class is responsible for the construction of QuizController
objects,
requiring a specific Quiz
and the current authenticated User
.
Usage Example:
QuizController controller = controllerFactory.quizController() .quiz(selectedQuiz) .currentUser(authenticatedUser) .build();
- Author:
- Justin.
- See Also:
-
Field Summary
Fields inherited from class ai.tutor.cab302exceptionalhandlers.builders.ControllerBuilder
db
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aQuizControllerBuilder
. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds aQuizController
.currentUser
(User user) Sets the current authenticated user for theQuizController
.Sets the quiz for theQuizController
.
-
Constructor Details
-
QuizControllerBuilder
Constructs aQuizControllerBuilder
.- Parameters:
db
- TheSQLiteConnection
to be used for database operations.
-
-
Method Details
-
quiz
Sets the quiz for theQuizController
.- Parameters:
quiz
- TheQuiz
to be associated with the controller.- Returns:
- This
QuizControllerBuilder
instance for chaining.
-
currentUser
Sets the current authenticated user for theQuizController
.- Parameters:
user
- The authenticatedUser
.- Returns:
- This
QuizControllerBuilder
instance for chaining.
-
build
Builds aQuizController
.- Specified by:
build
in classControllerBuilder<QuizController>
- Returns:
- A new instance of
QuizController
. - Throws:
IllegalStateException
- if the quiz or current user is not set.RuntimeException
- if a database connection error occurs during controller construction.SQLException
- if a database access error occurs during controller construction.
-