New lab partners, new friendsIt is time to switch lab partners! You may not work with a partner with whom you have previously worked this semester. Choose someone you haven't already worked with and relocate so that the two of you are sharing a single workstation. Sharing is caring, and also the key to good pair programming.
Switching pilot and co-pilotIn previous labs you were switching pair-programming roles in-between exercises. In this lab and in future labs, you will switch roles at regular intervals throughout the lab. The teaching assistants and tutors will announce that it is time to switch roughly every fifteen minutes.
Don't delete as you goIn previous labs some students deleted their solutions for exercises after completing them—don't do this! It is common for later exercises to make use of functions and templates introduced in earlier ones.
DR uber allesRemember to practice using the design recipe when designing programs!
Develop means Design RecipeUse it, love it.
Don't Use IEYou will be unable to see the exercise numbers if you use IE.
Develop a program that consumes a lab section and returns a descriptive
string similar to
"CS 2501 Section 3: George Washington, John Adams".
Hint: in the following exercises give names to your examples so you can use them again later.
trueif the name matches the name of the band and
In the following exercises, represent the world as a struct with two
posns. The first
posn represents the current
position of a blue circle, and the second
posn represents the
current position of a red circle. When the user clicks the mouse the red
circle will immediately move to where they clicked, and over time the blue
circle will move to meet it.
mouse-handlerto react to mouse events. It consumes four inputs: a World, an x coordinate, a y coordinate, and a MouseEvent as described in
MouseEvent. When the MouseEvent is
mouse-handlershould create a World where the first
posnis the same as the given World's first
posnand the second
posnis the position of the mouse click. On any other mouse event (
"leave") the function
mouse-handlershould return the given World unchanged.
tick-tockto react to clock events. The purpose of the function is to gradually equate two
posns as the clock progresses. The function consumes a World and produces a new World where both coordinates x and y of the first
posnare increased or decreased by 1 (or 0) so that they approach the coordinates of the second
For example, if the input World is ((1,3), (5,1)) then
should return the new World ((2,2), (5,1)).
world-drawthat consumes a World and returns a 300 × 300 scene with a solid blue circle of radius 15 at the position represented by the first
posnand a solid red circle of radius 10 at the position represented by the second
posn. When they overlap, the red circle should appear on top of the blue circle.
big-bangand the three functions you wrote to create an animation where you click to place a red circle somewhere in the canvas and then a blue circle moves along the canvas trying to reach the red circle. The initial position of the blue circle is determined by how you choose to initialize the World. You'll need
world-drawto use this String to determine the color of the circle we draw when the user clicks. Also write a function
cycle-colorto cycle through the colors:
"red". Using this function, modify
mouse-clickto cycle the color when the user clicks.
If you had trouble finishing any of the exercises in the lab or homework—or just feel like you're struggling with any of the material—come to office hours to talk to a TA or a tutor for extra help.