Multiple clocks

The goal of this lab is to write the program I talked about in class today that displays multiple clocks representing various different time zones. You will write this program using appropriately designed functions and procedures that will make the programming much easier and more easily understood than the code you have written up to this point.

We are providing a starting point for your program, namely the program shell I talked an\bout in class. You can obtain this program shell and a working solution executable by copying the following files:

      ~mc38/labs/many-clocks/many-clocks.cc
      ~mc38/labs/many-clocks/solution
The file many-clocks.cc will compile and display a message telling (briefly) you what to do. You should also probably run solution so that you know what your goal is.

Check-offs (2 points): When we check you off, we'll verify that you have:

  1. Documentation for the program, documentation for the procedure angleOfHourHand, and an appropriately written Makefile.

    As the book describes, documentation involves comments at the head describing what the program does, and a brief comment at the head of each procedure saying what the procedure computes. Since you'll choose clear variables and procedure names, each comment can be quite short. Remember to state any preconditions, if there are any.

  2. The procedures angleOfMinuteHand, radialSegment, and drawTick, including testing and documentation.

    You can demonstrate testing either by code in your main (which you'll later remove) or set's in your gdb buffer.

  3. The procedures drawClock and drawLabeledClock, including testing and documentation.

  4. Write main so that the program does what it should.

Animating your clocks (optional)

You can animate your clocks if you wish. Add a second hand so you can see the animation. You'll need a few new ideas:

  1. You'll need to clear the graphics window and redraw. See page 657 for a summary of the graphics commands.

  2. If you refresh too often, the window will blink anoyingly. Use sleep(1) to sleep for 1 second between refreshes. When you type man -k sleep, there are a couple relevant entries:
    sleep                (1)  - delay for a specified amount of time
    sleep                (3)  - Sleep for the specified number of seconds
    
    One of these, from Chapter 1 of the on-line manual, is a Linux shell command, and the one from Chapter 2 is a C library command. To learn about the sleep from Chapter 3, type,
      man -3 sleep

  3. Lastly, the graphics window buffers graphics. It only get around to displaying your graphics when (a) the buffer gets full, (b) you perform a get_mouse or (c) you exit. The following code will fill the buffer and force a redraw:
      for (int i=0; i<50; i++)
         cwin << Point (10,10);