6.6

Assignment 5

home work!

Programming Language BSL

Due Date Thursday 9/27 at 9pm

Purpose To design a small program using structured data.

Expectations
  • This assignment (and all future assignments) should be submitted with your lab and homework partner (assigned in lab on September 25th). Do NOT work on this assignment alone. You and your partner only need to make ONE submission (that is, both of you don’t have to submit since if one of you submits it counts for both of you).

  • You should submit a single .rkt file containing your responses to all exercises via the Handin Server. We accept NO email submissions.

  • You are only allowed to use the language specified at the top of this page: failure to do so will result in a 0.

  • All steps of the design recipe are required.

  • Be sure to use helper functions when appropriate to keep code clear.

Graded Exercises

Exercise 1 Design a data definition Minute which represents a minute in the day. It is up to you how to represent this data, but it should be able to encapsulate everything from 00:00 to 23:59 (or 12:00am to 11:59pm).

Your data definition should use a well-designed structure. Exactly what fields you use and how many you use are up to you, but be sure that something like 27:05 or 1:79 would not be a valid Minute according to your data definition.

Exercise 2 Design a function next-minute which given a Minute outputs the next Minute in the day (or returns midnight in the case of 23:59/11:59pm).

Exercise 3 Design a function draw-minute which given a Minute renders the time as an image as it would be displayed on a digital clock. The digital clock should be a 12-hour one, so 3 minutes past noon should display as 12:03pm. Don’t worry about the aesthetics so long as it is clearly displayed.

Exercise 4 Design a world program main/clock which takes in a Minute and simulates a 12-hour digital clock by quickly cycling through the minutes in a day (starting at the given Minute). When it reaches 11:59pm, it should then go to 12:00am and begin the cycle anew.

The output of the function should be a number indicating the number of simulated minutes that have passed when the program exits since the clock most recently displayed 12:00am. For example, if the user closes the window when the clock was showing 2:21am, the function should return 141.