Due Date: Thursday 05/14 at 10pm
Purpose: To design World programs; to practice designing and using structured data
You must submit a single .rkt file containing your responses to all exercises via the Handin Server. We accept no email submissions.
You must use the language specified at the top of this page.
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 revisit it before submitting each assignment.
Unless otherwise stated, for all programming problems you must provide (i) a signature, (ii) a purpose statement, (iii) sufficiently many check-expects, and (iv) the actual code, in the language specified at the top of this page.
Failure to comply with these expectations will result in deductions and possibly a 0 score.
Exercise 1 Consider the following structure definitions:
(define-struct lecture-hall (number capacity)) (define-struct automobile (year make model)) (define-struct football-player (name position number)) (define-struct shirt (material size color))
What are the names of the constructors and the selectors that each of the structures adds to Racket?
Provide data definitions for the structure definitions above. Make appropriate assumptions about what data goes with which field.
Develop templates for functions that consume the structures above.
Exercise 2 Here is a data definition for measuring time:
(define-struct time (hours minutes)) ; A Time is a (make-time Hour Minute) ; interpretation: (make-time h m) is the time ; expressed in h hours and m minutes ; ; – An Hour is a NaturalNumber between 0 and 11 ; – A Minute is a NaturalNumber between 0 and 59
Design the function tock, which adds one minute to the given time.
Design the function time->text, which converts a time to a text. The text should look like the display of a common alarm clock, i.e., it should separate the minutes from the hours with a colon. Hint: a text is an image, not a string, but you will need a string version of the time, too. See the HelpDesk for more on the text function.
After you have developed these functions, add a main function, which launches a big-bang program to animate the time.