For all the programming assignments, be sure to follow the design recipe. Write your function contract, examples, and function definition in the Definitions Window, save it to a file, and send me this file. Also test your program: since you've already included examples in the Definitions window, you should be able to hit the Execute button and see all the results (along with what you said they "should be"). Save the resulting Interactions window to a text file and send me this file too. Be sure to choose meaningful names for functions and parameters, and watch for opportunities to re-use functions you, I, or the textbook have already written.
Also turn in a log of how many errors of different kinds you encountered in the assignment, with brief comments describing each one ("mismatched parentheses" is self-explanatory, but more complex errors might need more description). You may do this using the PSP forms, or simply by keeping track in a text file or on paper and turning it in.
Fill out the class survey on the Web.
Read, in How to Design Programs, from the preface through chapter 2 (by Tuesday), chapter 3 (by Wednesday), and chapter 4 (by Thursday).
Skim Adages on Software Design and Development (I expect you to read all this stuff eventually, at your own pace.)
Write a few paragraphs on your reaction to the above reading assignments, and turn them in by email to Dr. Bloch. Be sure to include your name!
Develop a function named rect-perimeter
which
takes the width and height of a rectangle and returns its
perimeter.
Develop a function named convert-3-digits
which
takes in three numbers (the hundreds, tens, and ones places of a 3-digit
number, in that order) and returns the 3-digit number. For example,
(convert-3-digits 4 2 5)
should return the number 425. Note that Scheme doesn't have an
operation for "put this number next to that one"; you have to use
arithmetic operations like +, -, *, /.
Next, develop a function named
convert-3-reversed
which takes in the ones, tens, and
hundreds places of a 3-digit number, in that order, and returns the
3-digit number. For example,
(convert-3-reversed 5 7 2)
should return the number 275. Hint: re-use an old
function!
Do (but don't turn in) all the exercises from section 2.4 of the textbook (the ones about errors).
Develop a function can-vote?
which takes
in a person's age and returns a Boolean indicating whether that person
is old enough to vote.
Develop a function can-vote-but-not-drink?
which takes in a person's age and returns a Boolean indicating whether
that person is old enough to vote, but too young to drink alcohol.
Develop a function blot
which
takes in an image and a symbol (a color, e.g. 'blue
,
'red
, etc.) and returns the same image with the center
covered by an oval of the specified color.
Develop a function center-image+
which
takes in two images and returns an image with the second centered over
the first.
Develop a function bullseye
which
takes in a number and returns an image of a target of that size, with at
least three colors of concentric disks.
Develop a function that does something fun with images,
using some combination of image-above
,
image-beside
, reflect-vert
,
reflect-horiz
, rotate-cw
,
rotate-ccw
, and rotate-180
.
Survey: /5
(I'm not grading on what you say, only on whether you filled it
out.)
Essay: /30
(Grading primarily on content: convince me that you've read some of
the adages and thought about them.)
Error log: /15
(I'm not grading on how many or how few errors you encountered,
only on whether you recorded them correctly.)
Function name | Contract | Examples | Definition | Test results |
---|---|---|---|---|
rect-perimeter |
/5 | /5 | /10 | /5 |
convert-3-digits |
/5 | /5 | /10 | /5 |
convert-3-reversed |
/5 | /5 | /10 | /5 |
can-vote? |
/5 | /5 | /10 | /5 |
can-vote-but-not-drink? |
/5 | /5 | /10 | /5 |
blot |
/5 | /5 | /10 | /5 |
center-image+ |
/5 | /5 | /10 | /5 |
bullseye |
/5 | /5 | /10 | /5 |
something fun with images | /5 | /5 | /10 | /5 |
Following directions | /10 |
Writing contracts from word problems | /10 |
Choosing examples | /10 |
Choosing names | /10 |
Coding | /10 |
Code re-use and function composition | /10 |