Clock
classHere are all of the methods you need to write to get the clock class to work:
__str__
: create string with clock info in itgetTime()
: similar to str...just returns "hh:mm:ss" tick()
: advance the clock by 1 second (and take care of rollovers)Once you have the clock class written, the digital-clock.py
program should
display a clock using Zelle graphics.
Suppose we want to turn this into an alarm clock, that flashes red when the alarm is going off. What do we need to add to the clock class to get this to work?
In particular, I would like to be able to do something like this to set the alarm:
digclock.setAlarm(h,m,s+10)
And then something like this to see if we are in the alarm "state" or not:
if digclock.inAlarm():
gw.setBackground("red")