6.6

Assignment 4

home work!

Programming Language BSL

Due Date Monday 01/28 at 9pm

Purpose To practice using Posns and building world programs.

Expectations
  • You should submit a single .rkt file containing your responses to all exercises via the Handin Server. We accept NO email submissions. Failure to submit a .rkt file will result in a 0.

  • You are only allowed to use the language specified at the top of this page: failure to do so will result in a 0.

  • Your code MUST conform to the guidelines outlined in the style guide on the course website. The style guide will be updated as the semester progresses so please remember to read it before submitting each assignment.

  • You must follow all the steps of the design recipe when completing this assignment.

  • Please be sure to look at the feedback for assignment 2 before submitting, as we will be grading you more harshly on things we have warned you about before.

Graded Exercises

Exercise 1 Complete exercise 64 in the textbook.

Exercise 2 Design a function within-circle? which is given two Posns and a Number representing the radius of a circle. This function should produce a Boolean indicating whether the first position is located within a circle which is centered at the second position and has the given radius. Remember that when we design functions that produce a Boolean your purpose statement should be a question that the function answers.

Exercise 3 Design a world program dot-clicker, which is given a Posn. The Posn is the location of a dot on the screen. When the user clicks on this dot, the dot will disappear and a new dot will appear at a new random location on the screen. You can make the dot any size and color you like but if the dot is larger, the game should be easier, since the user can click anywhere in the dot to change its location.

Note: There is a section on the style guide about testing functions that use random.

Exercise 4 In a comment, describe the difference between Posn and make-posn.

Exercise 5 Design a world program dot-mover, which is given a Posn. The Posn is the location of a dot on the screen. When the user presses the arrow keys the dot will move in the direction given (so pressing the right arrow key should move the dot right, pressing the up arrow key should move the dot up, etc). If the dot moves past the edge of the screen it should wrap around to the other side. As before you can make the dot any size and color you like. Your program should not break when the user presses a non-arrow key.

Note: Be sure to re-use functions where you can. As programmers we try to avoid duplicate code whenever possible.