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.
define-struct
. Give two examples of time structures, explain in comments what they represent.
check-expect
tests.
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.
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.
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.
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.