CS 117: Introduction to Computer Science

Drawing an Analog Clock

Lately, we have been working with John Zelle's graphics.py module. His module includes the GraphWin class, as well as a collection of objects that can be drawn in a GraphWin window (e.g. Circle, Oval, Rectangle, Line, etc.). For this assignment, you will add a new object for drawing in a GraphWin: a clock.

The clock.py module already contains most of the code you will need. It includes a constructor, a complete collection of accessor methods, and a test program. It also includes stubs for a draw() method and a method called addMinutes(). Your job will be to implement these two methods (enhancing the test code as you see fit), and submit the resulting clock.py file.

For the draw() method, you will draw a circular clock with two hands and appropriate markings for the hours along the edge of the clock. The colors of the clock face and the numbers will be determined by the self.numberColor and self.faceColor variables. Make the hands the same color as the numbers. If you prefer small lines to mark the hours instead of numbers, that's OK.

The addMinutes() method allows the caller to change the clock's time easily. See the comments in clock.py for details.

A few notes and reminders:

Start early, have fun, and keep in touch.