CSC 160 Fall 2008 - Homework 2
Assigned Sept 8, due MONDAY Sept 22
Read Chapters 3-4 of Dr. Bloch's textbook.
Read this Definition
of a Program.
Read this article on Pair
Programming.
Do the following exercises from the textbook in DrScheme:
Exercise 2.1.3:
Store a picture in a variable. Then define another
variable named two-copies
whose value is two copies of that
picture, side by side, by using the previous variable. Then define a third
variable named six-copies
whose value is a six-pack of the
picture,
2 wide by 3 high, by using two-copies
.
Exercise 3.1.3
a) Define a variable named solid-green-box
whose value is a solid
green rectangle. Use a width of 10 and a height of 20.
b) Define a variable named
outline-blue-box
which is what it
sounds like. Use a width of 10 and a height of 20.
For parts c-g, use only the variable names. Do not use the pictures of
the rectangles or the expressions using the rectangle operation, or only half
credit will be given.
c) Write an
expression to put the solid box above the outline of a box.
d) Write an expression to put the solid box
on top of (not above) the outline of a box.
e) Write an expression to put the outline of
a box on top of (not
above) the solid box.
f) Write a full sentence describing why the
results of d) and e)
different. Make sure you put a semicolon at the start of that line to
comment it out.
g) Create a two by two checkerboard where the upper left and bottom right
corners have the solid box, and the upper right and lower left corners
have the outline of a box.
Exercise 3.2.1:
Write the function
contracts for ellipse
and circle
only.
For each
argument, include its data type then describe what that argument is
in parentheses. (Make sure this exercise is commented out, as discussed in
Section 3.3). Note: The contract for triangle
will be
given in class, so it is omitted from this exercise.
Exercise 3.4.4:
Hint: A circle's width and height are each twice the radius.
Exercise 3.4.5:
Note: For full credit, you must write a single
expression to do this. However, that single expression will have
subexpressions within it.
Exercise 3.5.2:
Note: You may use any picture of a
person's face for this question. It does not have to be the
picture in the textbook.
Do the following box diagram exercises from the
textbook on paper:
2.4.2: Draw a box diagram to prove that (rotate-cw
calendar)
is a legal expression. Assume that calendar is already
defined.
2.4.3: Draw a box diagram for each of the three expressions
in your solution to Exercise 2.1.3 to prove they are all legal
expressions.
3.7.2: Draw a box diagram to prove that (define tri
(triangle 15 "solid" "orange"))
is a legal expression. Assuming
that tri
is not already defined.
Submitting your Assignment
For this assignment, and all future assignments, your DrScheme files
(Definitions and Interactions) may not be submitted on paper.
Please submit your Definitions Pane and Interactions Pane through Moodle.
Be sure to include your first and
last name as a comment in the first line of your Defintions and
Interactions panes.
Please submit your Box Diagrams on paper in class by the due date.
The file name for the Definitions Pane needs to
be "hw2[LastName]Def.scm" where:
[LastName] is replaced with your last name.
For example, if I were submitting this
assignment, I would name the file
"hw2WittensteinDef.scm".
Similarly, the file name for the Interactions Pane needs to be
"hw2[LastName]Int.scm".
Please let me know if this is not clear or if you are unsure exactly
what filename to use. Part of your grade is using the correct filenames.
GRADING |
Question |
Point Value |
2.1.3 |
10 |
2.4.2 |
5 |
2.4.3 |
15 |
3.1.3 |
35 |
3.2.1 |
10 |
3.4.4 |
10 |
3.4.5 |
10 |
3.5.2 |
10 |
3.7.2 |
10 |
Filenames |
5 |
Total |
120 |
Last Modified: 9/21/08