Quiz App
Decks
Folders
Back
Summary
{deck: {name: "3a How to Design Worlds"}, score: [{question_type: "multiple_choice", label: "Multiple choice", graded: true, count: 0, total: 0}, {question_type: "short_answer", label: "Short answer", graded: false, count: 5, total: 5}], answers: [{question_prompt: "A world program represents a ball moving horizontally across the screen. The only changing information is the ball's x-coordinate. Define a data definition named BallWorld for the world state, include an interpretation, and write the basic template for a function that consumes a BallWorld.", question_type: "short_answer", choices: [], selected_choice: nil, response: "```racket\n; BallWorld is Number\n; interp. The horizontal X position of a ball\n(define (fn-for-bw) ... bw)\n```", correct: nil}, {question_prompt: "Write a big-bang expression for a world program that starts at 0 and uses tick as its on-tick handler, draw as its to-draw handler, and handle-key as its on-key handler.", question_type: "short_answer", choices: [], selected_choice: nil, response: "```racket\n(define (main ws)\n (big-bang ws\n (on-tick tick)\n (to-draw draw)\n (on-key handle-key)))\n```", correct: nil}, {question_prompt: "Write the signatures and stubs for three handlers: tick updates a WorldState every clock tick, draw renders a WorldState as an Image, and handle-key consumes a WorldState and KeyEvent and produces a WorldState.", question_type: "short_answer", choices: [], selected_choice: nil, response: "```racket\n(define (tick ws)\n (+ ws 1))\n\n(define (draw ws)\n (text ws))\n\n(define (handle-key ws ke)\n (cond [(string=? \"space\") (+ ws 10)]\n [else ws]))\n```", correct: nil}, {question_prompt: "A key handler should reset the world to 0 when the space key is pressed and otherwise leave the world unchanged. Write the handler and two check-expect tests: one for the space key and one representative unrelated key.", question_type: "short_answer", choices: [], selected_choice: nil, response: "```racket\n(define (on-key WS KE)\n (cond [(string=? KE \"space\") 0]\n [else WS]))\n\n(check-expect (on-key \"K\" 10) 10)\n(check-expect (on-key \"space\" 42) 0)\n```", correct: nil}, {question_prompt: "Explain the flow of information in a simple big-bang program after an on-tick event occurs. Describe what the tick handler receives and produces, what happens to that result, and how to-draw is involved.", question_type: "short_answer", choices: [], selected_choice: nil, response: "The `on-tick` function recieves the WorldState then should return a WorlState. The world program will then pass this to a to-draw function which should return an image which represents the world state", correct: nil}]}
Copy JSON