FACTORY METHOD / PRACTICE
Start a round.
Let its question vary.
You followed a vehicle from its creation hook back into dispatch(). Now build the same kind of boundary for quiz questions.
YOUR MISSION / QUIZ ROUNDS
Change the question.
Keep the round workflow.
A quiz framework gets a Question, calls ask(), then packages the prompt with the same heading and ten-point score. Math and science need different question objects.
Choose where creation belongs. Test both rounds, then add a word question through a new creator. As with delivery, setup selects the creator; its factory method creates the product.
01 / DESIGN THE CREATION BOUNDARY
Make three design choices.
Choose the product contract, decide where creation belongs, then wire up the caller.
Try your own design first. Hints and retries are unlimited.
02 / CREATE · RETURN · USE
One workflow. Different questions.
Start with math. Check that your workflow creates a question and returns its prompt with the common heading and score.
Setup selects: Choose a round
QuizRound.start()
- 1Obtain a Question
- 2Call question.ask()
- 3Package the card
Choose a round
Setup will choose which round to instantiate.
createQuestion()Overrides creation onlyNo question object yet
The selected round exists first. A Question is created during the trace.
The finished quiz card appears after the workflow uses the question.
Your choices drive this trace. Test both rounds to check the design.
Each trace starts a fresh round. Changing a design choice clears all verification.
See the code behind your design TypeScript
03 / EXTEND THE QUIZ
A word round joins the quiz.
It asks “What is the opposite of quiet?” and uses the same heading and ten-point score. Which edits add this round while preserving the shared workflow?
First finish passing Math and Science traces with the same assembly.
Compare with a complete solution
No timer and no attempt limit. Use hints, retry, or reveal the answer whenever it helps.