RU beehive logo ITEC dept promo banner
ITEC 380
2011fall
ibarland

homelecturesexamshwsbreeze (snow day)

hw01
intro; racket warm-up

MoWeFr section: Due Sep.07 (Wed) 17:00 (but hopefully you'll have it by class) (both hardcopy, and on Desire2Learn).
Thu section: Due Sep.08 (Thu) by class (on Desire2Learn). Your name and the assignment-number must be in a comment at the start of the file.

In the MWF section, we'll talk about test-cases (“check-expect”) on Monday (and, we'll emphasize not-repeating-code). However, I encourage you to finish as much as you can by Monday's class. Also, if any test-cases don't pass, say as much in a comment at the start of that problem. The Thu-only section doesn't need to include any test cases for this homework.

Note that some of the reading questions originally included here have been deferred for a week or two, for those who are still awaiting their textbook.

The exercises below are from the (free, online) book How to Design Programs. In DrRacket, set your language to “Beginning Student”: Language > Choose Language… > How to Design Programs > Beginning Student.

  1. (5pts) 2.2.1. (f2c) (MWF section: Three test-cases are also required; we'll discuss Monday.)
    Btw: A helpful explanation of temperature scales.
  2. (3pts) 2.4.1 [Just report the error message, explain in a few words, and give a fixed version.]
  3. (15pts) In the following exercises, do not repeat any code; call an existing function instead. (For example, there should only be one function in your entire code which multiplies pi by a radius.) If you create the right helper-method for 3.3.3, then 3.3.4 will be pretty easy to implement.

    MWF section: At least two test cases required for each (at least one non-trivial). For inexact (floating-point) calculations, check-expect isn't quite what we want; instead use check-within with a delta of 0.01 or so.

  4. To experiment with functions-which-create-and-handle-images in DrRacket, select Language > Add Teachpack… > HtDP/2e Teachpacks > image.ss. Then you should be be able to evaluate each of the following:
    (rectangle 80 20 'solid 'blue)
    (circle 20 'solid 'red)
    (ellipse 80 20 'outline 'orange)
    
    (beside (rectangle 80 20 'outline 'blue)
            (circle 20 'solid 'red))
    (overlay (rectangle 80 20 'outline 'blue)
             (circle 20 'solid 'red))
    ; Think of 'overlay' and 'beside' as being "addition for images"
    
    ; overlay with an offset:
    (overlay/offset (rectangle 80 20 'outline 'blue)
                    0
                    10
                    (circle 20 'solid 'red))
    
    
    ; If you want to explore documentation:
    ;   In DrRacket, position the caret on a function-name
    ;   like 'overlay', and hit F1.
    
    1. (2pts) Write a method which takes in a size, and returns an image of a donut. (Mmmm, doughnut.)
    2. (3pts) Write a method eye which takes a size and a color, and returns an image of an eye.
      (Your code for eye should probably not call donut; we can talk about why, in class.)
    Examples:

    You don't need check-expects for these.

See also scheme-resources.html.

homelecturesexamshwsbreeze (snow day)


©2011, Ian Barland, Radford University
Last modified 2011.Sep.17 (Sat)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Powered by PLT Scheme