'''SpecialPolygon'''
import turtle # again...
from poly import Polygon

class SpecialPolygon(Polygon):

    '''A Polygon where you can specify the colour, drawing speed, and
    direction.
    '''

    def __init__(self, n, b, x, y, c, s, d):
        '''Create a Polygon(n, b, x, y) that is colour c and will
        be drawn at speed s (an integer), and in direction d (one of 'cw'
        or 'ccw'.
        '''
        
        Polygon.__init__(self, n, b, x, y)
        self.color = c
        self.speed = s
        self.direction = d

    def draw(self): # override draw!
        '''Draw this polygon, starting at (x,y), make it have n sides,
        base of length b, colour c, draw it with speed s and in direction
        d.
        '''

        (n, b, x, y) = self.get_params() # inherit get_params!
        t = turtle.Turtle()
        t.setx(self.x)
        t.sety(self.y)
        t.speed(self.speed)
        t.color(self.color)
        t.begin_fill()
        for s in range(n):
            t.forward(b)
            if self.direction == 'ccw':
                t.left(360.0 / n)
            else:
                t.right(360.0 / n)
        t.end_fill()
        
        
if __name__ == '__main__':
    p1 = Polygon(5,50,0,0)
    p1.draw()
    p2 = SpecialPolygon(5, 50, 0, 0, 'blue', 5, 'cw')
    p2.draw()

    
