## CSci 1301: Problem Set 3

#### Due: Friday, September 27 at 11:59pm by e-mail

Please test all your programs carefully and include all the test cases with your program. You should have at least 3 tests for each function, except the ones that produce an image or a scene.

How to run a world program:

1. Click run (or press Ctrl-R) to run the program. This loads your program. Note: make sure to re-run (i.e. re-load) after every change!
2. In the interactions area (the bottom part) type ```(main 10)``` (10 is the number of seconds you want to run your program for; change this number as needed), press enter.

### Problem 1 (15 points)

Your task is to clean up and finish the example that we did in class. Specifically, you need to do the following:

1. Write your name and the problem set number in comments at the top of the file (always a required step).
2. Make the font size and the color of the string into global constants so that they can be changed easily. Change them and make sure the result changes accordingly. You may find other fixed numbers (the book refers to them as "magic numbers") that can be abstracted away into constants, do that as well.
3. Add a function `punctuation-color` that, given a character, returns the color according to the following rules: "red" for "!", "yellow" for "?", "blue" for "." and "black" for everything else. Write its signature (description of the parameters and the function, as we did in class). Write `check-expect` tests for your function, such as
``````
(check-expect (punctuation-color "!") "red")
``````
Test the function thoroughly.
4. Use the function you wrote in the previous question to display the string with the outline of a specific color, as determined by `punctuation-color`. Add new functionality one step at a time, test after every addition.

You might want to add more helper functions. Recall that you have written a function that returns the last character of a string as a part of the previous problem set, feel free to use it here (copy its check-expect tests into this file as well). Write signatures for all functions that you define and check-expect tests for all functions that do not return images.

5. Make sure your program is correct (test it thoroughly), well-organzied (refactor it as needed), and well-documented (all functions must have accurate signatures).

### Problem 2 (12 points)

Exercise 49 in section 4.3.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.