CSC 160 Fall 2014 - Homework 12 (100 points)
Assigned Nov 24, Due MONDAY Dec 1

1) Assignments with time stamps during class time (Mon or Wed 4:15-5:30pm) will be given a grade of ZERO.
2) In the spirit of the pair programming article that you read and summarized in HW5, this week's homework assignment may be done in pairs. If you choose to work in pairs, you must find time outside of class to work together in person at one computer. As per the syllabus, you cannot "pair-off" with the same person more than once during the semester. If you choose to do the assignment in pairs, please submit one copy through Moodle where both last names are used in each file name and both names appear as a comment at the top of each pane (Definitions and Interactions).
3) Start this homework as soon as possible so that you have time to get any help you may need from the instructor or course tutor prior to when the assignment is due.
4) Do not start the exercises until to have fully read and fully understood the corresponding textbook sections. If there is something you do not fully understand, you must contact the instructor or course tutor prior to starting the assigned exercises.


[100 (+40) pts.] Chapter 20A
Read Sections 20.1-20.4 of the textbook.

Do the following exercises in DrRacket (show all Design Recipe v2 steps whenever you Design a Function):
  • Design the function: on-top?. It takes a point and returns true if it is in the uppermost 50 pixels of the window.
  • Exercise 20.4.2: Design the function: above-diagonal?. It takes in a posn and returns true if the point is above the diagonal. [Hint: In Racket, the diagonal goes from the top left corner (also known as the origin) to the bottom right corner.]
    BEFORE CONTINUING, TYPE THE DEFINITION OF THE DISTANCE FUNCTION FROM THE CHAPTER 20 LECTURE SLIDES INTO THE DEFINITIONS PANE.
  • Design 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!)
  • Extra credit: Design 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 circle. For full credit, you need to design a helper function that finds the area of a circle, using the formula A = pi * r * r, then have find-area call that function.


    GRADING Contract Purpose Data Analysis Examples Skeleton
    w/Inventory
    Add details
    to skeleton
    Definition
    30 points: on-top? /2 /1 /3 /3 /3 /3 /15
    30 points: Exercise 20.4.2 /2 /1 /3 /3 /3 /3 /15
    40 points: within-distance? /2 /1 /3 /3 /5 /6 /20
    Extra Credit: find-area /4 /2 n/a /6 /4 /4 /20



    Last Modified: 11/19/14