Week 6 Set b
Due Date Thursday 10/11 at 9:00pm (Week 6)
Purpose To further your implementation of Minicraft and begin using higher-order operations.
Language change!
As noted above, please submit this assignment in Intermediate Student Language as opposed to BSL+.
Finger Exercises
We strongly recommend completing the following finger exercises.
Exercise 1 Revisit the GC data definition from two weeks ago. Design the function update-gc, which given a GC, the name of a food, and a [Cost -> Cost] function, applies that function to the previously associated cost of that food and leaves the rest of the catalogue untouched. If no such food was present, make a reasonable decision about what to do (there are at least two).
Exercise 2 Imagine, for a moment, you are a real-estate website programmer. One crucial data definition would be that of a House:
; A House is a (make-house String Number Number String Number) (define-struct house [address bedrooms bathrooms style value]) Actual real estate data dealing with houses have much larger (and usually poorly designed) data definitions, but that’s not our problem. Now, which of these values is likely to change over time? Only the house’s cost.
Let’s imagine a scenario in which the market dictates all houses with 2.5 or more baths become worth 1.1 times their current value, those with 2 or fewer bedrooms become worth 0.9 times their current value, and those with a "Colonial" style are all increased by 500 dollars. If more than one of these scenarios apply, then only the first one (as listed here) takes effect; if none do, nothing changes.
To implement this,
design a function that given a house and a [Number -> Number] function applies it to the house’s cost (and leaves the rest of the house as it is). Then,
demonstrate the usefulness of the function you just defined by using it in a function which applies the above scenario to a single house. Then,
demonstrate the usefulness of pre-defined list abstractions (listed below) by using one of them and the function you just defined to apply the above scenario to a list of homes.
Graded Exercises
Note that for the following problems, you must use foldr, filter, map, andmap and/or ormap when appropriate. You may also find build-list helpful.
Exercise 3 Respond to feedback on your Week 5 Set a (received both in lab and on the handin server) and update your data definitions and code as needed.
Exercise 4 Implement your to-draw handler for your Minicraft game. See the initial writeup for details.
Exercise 5 Implement your on-tick handler for your Minicraft game. See the initial writeup for details as well as the style guide for hints on how to structure this handler.