The Quiz Creator is a C# application that allows you to create and administer quizzes of various types, including single correct multiple-choice quizzes, multiple correct multiple-choice quizzes, and subjective quizzes. It utilizes the Template Method design pattern to define the structure of the quiz-taking process while allowing customization for different quiz types.
The Template Method design pattern is a behavioral pattern that defines the skeleton of an algorithm in the base class but lets subclasses override specific steps of the algorithm without changing its structure. In this application, the Quiz
class serves as the template with the following key methods:
AskCandidateDetails()
: Asks the candidate for their name and ID.DisplayInstructions()
: Displays quiz instructions.AskQuestions()
: Abstract method for asking quiz questions (customized by subclasses).CalculateScore()
: Calculates the candidate's quiz score.DisplayResults()
: Displays quiz results, including candidate details and score.
This quiz type allows candidates to select a single correct option (A, B, C, or D) for each multiple-choice question.
This quiz type allows candidates to select multiple correct options for each multiple-choice question. The template method calculates the score based on correct answers.
This quiz type includes open-ended questions, and candidates provide text answers. The template method ensures candidates provide answers for all questions.
- Create instances of the quiz types you want to administer.
- Customize quiz questions, correct answers, and instructions as needed.
- Call the
AttemptQuiz()
method to start the quiz-taking process. - Candidates will be prompted for their details, and then the quiz will be administered.
- The quiz results, including the candidate's score, will be displayed.
// Create a single correct multiple-choice quiz
var singleChoiceQuiz = new SingleCorrectMultipleChoiceQuiz(
questions,
answers,
instructions
);
// Start the quiz
singleChoiceQuiz.AttemptQuiz();