from shape import Shape
import turtle

class Square(Shape):
    '''
    Represents geometric square lined up with axes

    position: inherited from Shape
    base: float               --- length of base of this Square
    move_to: inherited from Shape
    '''

    def __init__(self, x, y, b):
        ''' (Square, float, float, float) -> NoneType

        Initialize square self located at (x, y) with base b.
        '''
        # extends method from Shape
        Shape.__init__(self, x, y)
        self.base = b

    def draw(self, t):
        ''' (Square, Turtle) -> NoneType

        Draw square self using t.
        '''
        # override Shape.draw
        t.color('red')
        t.up()
        t.goto(self.position)
        t.down() # tail down, ready to draw
        t.begin_fill()
        for s in range(4):
            t.forward(self.base)
            t.left(90)
        t.end_fill()

    def get_area(self):
        ''' (Square) -> float

        Return the area of square self.

        >>> Square(0, 0, 20).get_area() == 400.0
        True
        '''
        return float(self.base * self.base)


if __name__ == '__main__':
    import doctest
    doctest.testmod()
