CSC 160 Fall 2012 Homework 12
Assigned Dec 10, Due MONDAY Dec 17

1) This assignment will NOT be accepted late for any reason, since solutions will be posted to Moodle Tuesday morning (12/18).
2) Assignments with time stamps during class time (Mon or Wed 4:15-5:30pm) will be given a grade of ZERO.
3) 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).
4) 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.
5) 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.


Assigned M 12/10
Textbook Reading (to review today's class):
  • Read Sections 20.1-20.4 (up to p.257) of the textbook.

    Do the following exercises in DrRacket (show all Design Recipe v2 steps whenever you Design a Function, including a sufficient set of test cases and a Data Analysis):
  • 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.]

    Textbook Reading (to prepare for next class):
  • Read Section 20.4 (p.257-259) of the textbook.


    Assigned W 12/12
    Textbook Reading (to review today's class):
  • Read Section 20.4 (p.257-259) of the textbook.

    Do the following in DrRacket (show all Design Recipe v2 steps whenever you Design a Function, including a sufficient set of test cases and a Data Analysis):
  • BEFORE CONTINUING, COPY AND PASTE THE DISTANCE PROGRAM 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 disk enclosed by the circle. Remember that the Area of a disk = PI * r * r. (Hint: You will need to call the distance function written in class! You may also want to design and then use an auxiliary function area-of-disk.)
  • Extra Credit - Exercise 20.5.3: Design a function named scale-posn which takes in a number and a posn, and returns a posn formed by multiplying the number by each of the coordinates of the input posn. For example, (scale-posn 3 (make-posn 2 5)) "should be" (make-posn 6 15).





  • Grading Contract Purpose Data Analysis Examples Skeleton Inventory Add details
    to skeleton
    Definition Testing
    32 points: on-top? /2 /1 /3 /3 /2 /2 /2 /15 /2
    32 points: Exercise 20.4.2 /2 /1 /3 /3 /2 /2 /2 /15 /2
    36 points: within-distance? /2 /1 /3 /3 /2 /3 /4 /16 /2
    Extra Credit: 20.5.3 /2 /1 /2 /2 /2 /2 /2 /10 /2
    Extra Credit: find-area /2 /1 /2 /2 /2 /2 /2 /10 /2



    Last Modified: 12/10/12