RU beehive logo ITEC dept promo banner
ITEC 380
2012fall
ibarland
tlewis32

homelecturesexamshwsbreeze (snow day)

hw01
intro; racket warm-up

Due Sep.05 (Wed) (both hardcopy, and on Desire2Learn).
Your name and the assignment-number must be in a comment at the start of the file. Your hardcopy must be stapled.

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 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 squares the radius.) If you create the right helper-method for 3.3.3, then 3.3.4 will be pretty easy to implement.

    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—ITEC380 Scheme resources.

homelecturesexamshwsbreeze (snow day)


©2012, Ian Barland, Radford University
Last modified 2012.Oct.15 (Mon)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Powered by PLT Scheme