At home you may want to do some review reading and practice. You should be able to do review questions 1 and 2 in one day, and question 3 in a second day. Ask if you have questions!
Reading the book and looking at old exercises is a very productive way to study. Struggling in Chapter 21 (new structures)?
Other good chapters to read are: 20 (posn and color), and 17 (animations using cond).
Red-blue. Standard dice have 6 sides, numbered 1 through 6. Play a game with a standard blue die and two standard red dice. The number of points you get is ten times the blue roll plus three times the sum of the other two. Except you get zero points if your red dice total 4. Design and test the red-blue
function.
red-blue: any(ignore) -> number(points)
Spam-circle. Every time you click, a circle appears centered on the mouse. The color of the circle changes is red the first click, green the second, blue the third, red the fourth, and so on. Choose one option:
Advanced variations:
Rectangle Limitations. This will take a while. As you work on it, keep the design process in mind. Have a signature, purpose, and tests for every function.
The animation: as you move the mouse on the screen, a small circle follows the mouse.
At the start of the game, the circle is restricted to the rectangle 100<=x<=200 and 150 <= y <= 250.
That means that if the mouse is outside of that rectangle, the circle will stick to one of the rectangle’s walls.
After t seconds, the circle can move in the larger rectangle 100-10t <= x <= 200+10t and 150-5t <= y <= 250 + 5t.
After 10 seconds the animation ends.
Breakdown of the creation process:
m-set-pt: m(model) posn(new-point) -> m(new-model)
… what should this function do? Look back at Chapter 21 Worksheets B and C if needed.limit-pt: posn(upper-left) posn(lower-right) posn(pt) -> posn (new-pt)
. This function makes a point that stays on the edge of the rectangle if pt is outside of the rectangle. Otherwise it does not change pt.limit-pt
to put the current mouse coordinates into the rectangle defined by the upper-left and lower-right posns in the model, then draw a circle there.