17.E
This worksheet addresses a number of challenging misconceptions. Read closely and consider you answers thoughtfully.
Expanations
You are given some information and asked about other functions. Explain how to write the other functions or why the situation is impossible.
-
(Big Blue) Moving the mouse makes the blue circle increase its radius by 5.
(define (maus1 n x y event) (+ n 5))
- Write the signature of the mouse handler
maus1
. - Write the draw handler.
- Write the signature of the mouse handler
-
Using the setup from Big Blue above, the animation stops when the circle’s radius is at least 175.
- What is the signature of the stop-when handler’s
should-stop?
function. - Write the
should-stop?
function.
- What is the signature of the stop-when handler’s
-
(Small Orange) Moving the mouse reduces the orange circle to 95% of its current size. You are given the draw handler is
draw2
below.- Based on the draw handler
draw2
, what is the type of the model? - Write the signature of the mouse handler
oshrink
. - Write the mouse handler.
- Based on the draw handler
(define (draw2 mystery)
(overlay mystery (empty-scene 300 200)))
-
(Wide Green) Hitting a key makes the rectangle twice as wide as it was. The draw handler
dhwg
and the key handler iswg
(below).- Write the signature of the function
wg
, as shown below. - Make/describe a chart showing pressing the “a” key and then the “b” key. Begin with an initial model of 40. What is the model after hitting the “a” key? Then the “b” key? Is this animation going to work ok?
- Write the signature of the function
(define (wg model key)
(rectangle (* 2 model) 50 "solid" "green"))
(define (dhwg model)
(rectangle model 50 "solid" "green"))