'''A class for representing a simple graphical clock. Your job is to implement the draw and addMinutes methods. This class depends on the "graphics.py" library written by John Zelle for his textbook "Python Programming: An Introduction to Computer Science." ''' from graphics import * class Clock: def __init__(self, center, radius): ''' Initializes the Clock object's center (a Point) and radius (an integer). Sets the Clock colors to default values of black and white, and the time to midnight. ''' self.center = center self.radius = radius self.hours = 0 self.minutes = 0 self.numberColor = color_rgb(0, 0, 0) self.faceColor = color_rgb(255, 255, 255) def setCenter(self, center): self.center = center def getCenter(self): return self.center def setRadius(self, radius): self.radius = radius def getRadius(self): return self.radius def setTime(self, hours, minutes): self.hours = hours % 24 self.minutes = minutes % 60 def getTime(self): return self.hours, self.minutes def setNumberColor(self, color): self.numberColor = color def getNumberColor(self): return self.numberColor def setFaceColor(self, color): self.faceColor = color def getFaceColor(self): return self.faceColor def draw(self, window): ''' Draws this clock in the specified GraphWin object. The drawing should look like a standard circular analog clock, with either hash marks or numbers at the 12 hour marks, plus a big hand and a little hand indicating the current time. ''' print 'hi, you are in draw' pass def addMinutes(self, minutesToAdd): ''' Adds the specified number of minutes (positive or negative) to this clock's current time, adjusting self.hours and self.minutes accordingly. ''' print 'hi, you are in addMinutes' pass if __name__ == '__main__': # A simple test. Feel free to expand on this code to test your # work more thoroughly. # Instantiate a graphics window. window = GraphWin('Clock Test', 400, 400) # Instantiate a clock and give it red numbers on a blue face. clock = Clock(Point(200, 200), 150) clock.setNumberColor(color_rgb(200, 0, 0)) clock.setFaceColor(color_rgb(0, 0, 200)) # Set the time to 11:15PM. clock.setTime(23, 15) # Add two and a half hours. clock.addMinutes(150) # Draw the clock. Does it show a time of 1:45AM, with red numbers # and a blue face? clock.draw(window) s = raw_input('Hit Enter to quit')