CSC 160 Fall 2005 Homework 6
Assigned Nov 22, Due SUNDAY Dec 4
Read
Sections 6.0-6.1 of the
textbook (pages 51-54).
Submitting this Assignment
--You may complete this assignment alone or in pairs.
However you cannot use the same partner as HW4 or HW5.
--If you do the assignment in pairs, include both last names in each file
name.
--For each function, be sure to follow the design recipe.
--In the definitions window, write all the
function purposes, contracts, at least three
examples, skeletons, and function definitions.
--Submit one Definitions Window which includes all 3 questions. Save as
hw6[LastName]Def.scm.
--Submit one Interactions Window which includes the tests for all 3
questions. Save as hw6[LastName]Test.scm.
--Do not use conditionals for this assignment.
The Assignment
1. Develop the function: on-top?. It takes a point and returns
true if it is in the uppermost 50 pixels of the window.
BEFORE CONTINUING, COPY AND PASTE THE DISTANCE PROGRAM FROM THE CHAPTER 6
SLIDES INTO THE DEFINITIONS WINDOW.
2. Develop the function: within-distance?. It takes in two posns
and a number, and tells whether the posns are within that distance of one
another. (Hint: You will need to call the distance function written in
class!)
3. Develop the function: find-area. It consumes two Posn
structures -- one representing the center of a circle and the other
representing a point on its circumference -- and produces the area of the disk
enclosed by the circle. Area of a disk = PI * r * r. (Hint: You
will need to call the distance function written in class! You may
also want to call the area-of-a-disk program written in Chapter
2!)
| Grading |
Purpose |
Contract |
Examples |
Skeleton |
Definition |
Testing |
| Question 1 |
/4 |
/4 |
/4 |
/4 |
/20 |
/4 |
| Question 2 |
/3 |
/3 |
/3 |
/3 |
/15 |
/3 |
| Question 3 |
/3 |
/3 |
/3 |
/3 |
/15 |
/3 |
Last Modified: 11/22/05