CSci 1301: Lab 6

You may work in groups of 2 or 3 (preferred) or individually.

What to submit

At the end of the lab please send me and your group partner(s) all your Scheme files as e-mail attachments. My e-mail is elenam at morris.umn.edu. The subject of your e-mail must be "1301 Lab 6" followed by "Final" or "Not final", depending on whether this is a final submission or you are still working on it. If you need to finish it, make sure to set up a time with your group partner(s) to finish the lab.

When to submit

Due Friday, October 23rd, at 11:59pm. If you submit the final version during the lab, you are done.

Problem 1 (10 points)

Write a function `draw-stairs` that draws a "staircase" of a given color. More precisely, the function has the following header:

``````
(define (draw-stairs left-upper n width height color)
...
)
``````

where `left-upper` is the position of the left-upper corner of the staircase, `n` is the number of steps that remain to be drawn, `width` is the width of one stair, `height` is the height of a step, and `color` is the color of the staircase.
Below is an example:

``````
(draw-stairs (make-posn 10 10) 8 40 40 'green)
``````

Problem 2: Checker board (12 points)

Write a function `checker-board` that takes draws an 8-by-8 checker board of two colors. More precisely, the function is defined as

``````
(define (checker-board left-upper n side color1 color2))
``````

Here `left-upper` is the position of the left-upper corner of the board, `n` is the number of rows that remain to be drawn, `side` is the side of a square, `color1` is the starting color for the row, and `color2` is the alternating color.

The function requires a "helper" function draw-row that draws one row of the board. Write and test the helper function first. Think of what parameters it needs (what is its base case?).

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.