""" Demonstration of Inheritance """
from turtle import Turtle
from lectures.week2.point import Point
from lectures.week3.shape import Shape


class Square(Shape):
    """
    A square shape that can draw itself, move, and
    report area and perimeter.

    === Attributes ===
    @type corners: list[Point]
       corners of this square
    @type perimeter: float
       length to traverse corners
    @type area: float
        area of this Square
    """
    def __init__(self, corners, colour='blue'):
        """
        Create a new Square self with corners.

        Assume the corners are traversed in order, that
        the sides are of equal length, and that the vertices
        are right angles.

        Extended from Shape

        @type self: Square
        @type corners: list[Point]
        @rtype: None
        """
        # call a method in the superclass
        Shape.__init__(self, corners)
        self.colour = colour
        self.name = 'Fred'

    # need this method because setting the area of a
    # Square is different from setting the area of a Shape
    def _set_area(self):
        """
        Set the area of Square self to the square of
        its sides.

        Overrides Shape._set_area

        @type self: Square
        @rtype: None
        """
        self._area = self.corners[0].distance(self.corners[1])**2


if __name__ == "__main__":
    import doctest
    doctest.testmod()
    s = Square([Point(1, 1), Point(1, 2), Point(2, 2), Point(2, 1)])
    print(s.area)
    print(s.perimeter)
    s.draw()
