New lab partners, new friends
It 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-pilot
In 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 go
In 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 alles
Remember to practice using the design recipe when designing programs!Develop means Design Recipe
Use it, love it.Don't Use IE
You 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.
true if the name matches the name of the band and false otherwise.
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-handler to 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 "button-down" the function
mouse-handler should create a World where the first
posn is the same as the given World's first posn and the second
posn is the position of the mouse click. On any other mouse event
("button-up", "drag", "move", "enter", or "leave") the function mouse-handler should return
the given World unchanged.
tick-tock to 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 posn are
increased or decreased by 1 (or 0) so that they approach the coordinates of the
second posn.
For example, if the input World is ((1,3), (5,1)) then tick-tock
should return the new World ((2,2), (5,1)).
world-draw that consumes a World and returns a
300 × 300 scene with a solid blue circle of radius 15 at the position
represented by the first posn and 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-bang and 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 on-mouse, on-tick, and
to-draw.
"red", "yellow", or "green". Modify world-draw to use this String
to determine the color of the circle we draw when the user clicks. Also write a
function cycle-color to cycle through the colors: "red" → "yellow" → "green" → "red". Using this
function, modify mouse-click to 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.