Assignment 11
Due Date Thursday 02/28 at 9pm
Purpose To practice processing recursive data including (but not limited to) lists.
You should submit a single .rkt file containing your responses to all exercises via the Handin Server. We accept NO email submissions. Failure to submit a .rkt file will result in a 0.
You are only allowed to use the language specified at the top of this page: failure to do so will result in a 0.
Your code MUST conform to the guidelines outlined in the style guide on the course website. The style guide will be updated as the semester progresses so please remember to read it before submitting each assignment.
You must follow all the steps of the design recipe when completing this assignment.
Please be sure to look at the feedback for assignment 9 before submitting, as we will be grading you more harshly on things we have warned you about before.
You must submit this assignment with your partner. Please make sure you can submit with your partner before 5pm on Thursday or we cannot guarantee that you will be able to submit your homework before the deadline. If the course staff are unable to assist you after 5pm and this causes your homework to be late we will not grant an extension.
Exercise 1 Complete Exercise 140 in the textbook. Remember to provide any data definitions that are non-atomic and follow all the steps of the data design recipe.
Exercise 2 How could you improve the function names given in the previous exercise? Write your answer in a comment.
Exercise 3 Complete Exercise 142 in the textbook. You should NOT copy and paste images into your check-expects but you may define image constants to use in your test. Remember to provide any data definitions that are non-atomic and follow all the steps of the data design recipe.
Exercise 4 Complete Exercise 144 in the textbook. NOTE: You will need to read back a bit in the textbook in order for this exercise to make sense.
Exercise 5 Design a function which, given a Nat and an Image, draws that image the given number of times. The images should be shown beside each other. It will be helpful to recall the following data definition for a natural number:
; A Nat is one of: ; - 0 ; - (add1 Nat)
Consider the following data definition:
(define-struct building [name zip floors]) ; A Building is a (make-building String Nat ListOfStories) ; - where name is the building's name ; - zip is the building's zip code ; - and floors is a list of all the floors in the building ; A ListOfStories is one of: ; - '() ; - (cons Story ListOfStories) (define-struct story [height rooms color]) ; A Story is a (make-story PositiveInteger PositiveInteger Color) ; - where height is the height of the story (in pixels) ; - rooms is the number of rooms on this floor of the building ; - and color is the color of this floor of the building
Exercise 6 Complete the steps of the data design recipe for these definitions.
Exercise 7 Design a function which, given a Building produces the number of rooms in the Story with the most rooms in the whole building. A building with no stories should produce 0.
Exercise 8 Design the function draw-building which, given a Building draws it. The stories should be of a fixed width, be their own color, and stacked on top of each other. The stories should be stacked in order. In other words, a Story at the front of the list should be drawn above any Story that comes after it. Each story should consist of horizontally arranged, identically sized rooms, all of which are surrounded by a frame to differentiate between them. A building with no stories can be represented by the empty-image.