|
home—lectures—recipe—exams—hws—D2L—breeze (snow day; distance)
Due:
Sep.21 (Wed) 14:00 (hardcopy and D2L)
Your submitted file should be named “hw03.rkt” as plain-text (which is
what DrRacket saves as).
Standard instructions for all homeworks (unless instructed otherwise):
Open DrRacket (either in labs, or you can download it to your own computer from racket-lang.org). The first time you start DrRacket, it will ask you to choose a language; select Language > Use Language... > Teaching Languages > Beginning Student, for now.
Follow the design recipe, steps 2,3 if using a new data definition; and steps 4,5,7,8.
Data definition: A directory-response is one of:
(15pts) Write a function which, given a directory-response, returns a string: either
You can think of this function as being one part of a larger program which queries a campus-directory, such as radford's, and then has to use the response it gets.
NOTE: Your function will be given directory-responses: so if you're given a string, you can deduce (from this def'n) that its length is already in [1,14). This is not something you need to check for, or handle. You only need to distinguish between the three variants of a directory-response.
To think about:
As per the design recipe
since our data-definition has three different variants,
you will have a
To experiment with functions-which-create-and-handle-images in DrRacket,
include
(rectangle 80 20 'solid 'blue) (circle 20 'solid 'red) (ellipse 80 20 'outline 'orange) (beside (rectangle 80 20 'outline 'blue) (circle 20 'solid 'red)) (underlay (rectangle 80 20 'outline 'blue) (circle 20 'solid 'red)) ; Think of 'underlay' and 'beside' as being "addition for images" ; underlay with an offset: (underlay/offset (rectangle 80 20 'outline 'blue) 0 10 (circle 20 'solid 'red)) ; If you want to explore documentation: ; In DrRacket, position the caret on a function-name ; like 'underlay', and hit F1. |
For functions that return an image, your expected-value should either be (a) an expression involving calls to: the image primitives and/or previously-tested functions, OR (b) an image-literal (but, show the expressions you used to create that image-literal).
For example, if the problem were to "create a function that takes in a width, and returns a solid
purple rectangle with the given width and a 16:9 aspect ratio", then the "expected result" part
of the test cases might involve calling the image-library's functions like
(check-expect (screen 32) (rectangle 32 18 'solid 'purple)) (check-expect (screen 16) (rectangle 16 9 'solid 'purple)) (check-expect (screen 0) (rectangle 0 0 'solid 'purple)) ; Note: for the expected 0x0 rectangle, I could equally well write: (check-expect (screen 0) empty-image) |
You only need steps 4,5,7,8 of the design recipe (once you decide what how you'll represent "size", which is a straightforward choice), and we're only using existing, simple datatypes (so no steps 1-3 or 6).
home—lectures—recipe—exams—hws—D2L—breeze (snow day; distance)
©2016, Ian Barland, Radford University Last modified 2016.Oct.11 (Tue) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |