Excerpt from Description of Exercise

Objective: To gain experience using conditionals.

The Scenario.

We would like you to write a program that emulates a broom that can sweep an object around the screen. The broom will be represented by a small ball with diameter 10 that appears when the mouse is pressed and disappears when the mouse is released. While the mouse is depressed, the broom (i.e. ball) is dragged along by the mouse (the upperleft corner of the broom should always be at the mouse location). In the image below, the broom is partly hidden underneath the cursor arrow.

The ``dirt'' you are sweeping will be represented by a filled square (30 pixels to a side) shown on the screen. If the broom bumps into the square while being dragged (as shown in the image above), then the square will move the same distance (and in the same direction) as the broom, as it would if you had a real broom.

Handouts Describing the Exercise

Student Resources for Lab Exercise

Sample solutions