## CSci 1301: Problem Set 3

#### Due: Friday, October 9 at 11:59pm e-mail

Please test all your programs carefully and include all the test cases with your program. You must have at least 3 tests for each function, except the ones that produce an image or a scene. Use `check-expect` for testing, except possibly for images.

### Problem 1 (10 points)

1. Exercise 77 (3 points) in Chapter 5.7. Here data defintion is a description (in comments) of what a structure consists of, and structure type definition is the actual `define-struct`. Give two examples of time structures, explain in comments what they represent.
2. Exercise 81 (7 points) Chapter 5.8. Make sure to provide a contract and `check-expect` tests.

### Problem 2 (5 points)

Write a function `posn=?` that takes two position structures and returns #true if they have the same x and y coordinates and `#false` otherwise. Provide `check-expect` tests and a contract.

### Problem 3 (12 points)

Write a world program that displays a square divided into four quadrants of different color. The quadrants are shown as an outline. When the user clicks (i.e. presses the mouse button) on one of the quadrants, that quadrant becomes of a solid color. All other quadrants becomes outlined, in their respective color.

Here is what the canvas look like after the user clicks the top left quadrant:

As always, be pay attention to code quality: use of functions, well-chosen names, comments, etc.

### Problem 4 (10 points, 2 points of extra credit)

Exercise 53 in Chapter 4.3.

Important: the world state must be an enumeration of three strings: "red", "yellow", "green". The function `show` should convert it into the picture of the traffic light of that color. It's enough to have just one cicrle that vhanges color, but you can have a three-circle traffic light for 2 points of extra credit. The state of the traffic light changes on every clock tick. You may start the big-bang with any color.

### Problem 5 (12 points)

Exercise 110 in Chapter 6.2.

Start designing your solution by carefully deciding on what your world state will be. You might want to spend some time on thinking about different options. Read the problem carefully.
Make sure to describe your world state in comments right before main. Include `check-with` in your `big-bang` to check that your world state is in a valid state, it is a requied part of this problem.

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.