"""
A module for implementing Squares.
"""
from point import Point
from shape_str_eq import Shape


class Square(Shape):
    """
    A Square Shape.
    """

    def __init__(self, corners):
        """ Create Square self with vertices corners.

        Assume all sides are equal and corners are square.

        Extended from Shape.

        @type self: Square
        @type corners: list[Point]
        @rtype: None

        >>> s = Square([Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 0)])
        """
        Shape.__init__(self, corners)

    def _set_area(self):
        """
        Set Square self's area.

        Overrides Shape._set_area

        @type self: Square
        @rtype: float

        >>> s = Square([Point(0,0), Point(10,0), Point(10,10), Point(0,10)])
        >>> s.area
        100.0
        """
        self._area = self.corners[-1].distance(self.corners[0]) ** 2

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

    s = Square([Point(0, 0), Point(10, 0), Point(10, 10), Point(0, 10)])
    print(s)

    # Pycharm flags these, as it should, but only if using @param for corners
    # in the docstring for class Shape. Strange.. so let's use @param for better
    # type checking warnings.
    print(s.corners + "three")
    print(s.area + "three")
