This is individual work. You are not allowed to spend more than 6 hours on this test. This includes any reading that you do to help you solve the problems.
Make sure to write your name in the file(s) you submit. You may submit one or two files.
Use helper functions as needed.
All your functions (including all those you use
in big-bang
) must have documentation with the types of
parameters and results, a function description, and, whenever
possible, check-expect
tests.
When defining your own structures, clearly explain what all the fields mean.
Comments, helpful variable names, and good code style and formatting
are a very important part of your grade. You don't have to look for the
shortest solution, but you should eliminate unnecessary code repetition if
possible (use helper functions).
Write a function duplicate-middle
that consumes a
string
and if the string has an odd number of characters, it
returns the string in which the middle character is repeated twice.
If the string has an even number of characters, it is returned unchanged.
The following are some tests for the function; you need to add more tests
since there are cases that are not tested here.
Please make sure to write the signature and the (more precise) description.
(check-expect (duplicate-middle "a") "aa")
(check-expect (duplicate-middle "son") "soon")
Your goal is to implement an object that moves on the screen. The object
has a direction in which it's moving and is represented by a simple arrow
pointing in its direction, in this case "up":
I used the function
isosceles-triangle for this image. Your image may be the same or different, as long as it's using Racket image library (not an imported image).
The world program that you need to write is as follows:
do-nothing
. The to-draw function takes the world state and
returns the canvas with the arrow image on it at the coordinates
x and y and pointing into the direction of the structure. For instance,
when x and y are at the center of the canvas and the object is pointing
left, the canvas should look like this:
rotate
function for the new images.
If something is not working, please comment it out and write comments about why you think it's not working and how you would be going about fixing it if you had more time. Make sure that the code you submit runs, even if it doesn't implement all of the functionality.
Your work will be graded based on:
Submit all your files as attachements in an email to me with the subject "Midterm 1" followed by your name or initials. Please include your name and a task number at the beginning of each file, in a comment. In your email message please include any comments about what works and what doesn't, as well as thoughts on how you would've continued if you had more time (if you run out of time). Also please include the total time you spent on the test.