from point import Point
from shape import Shape


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

    def __init__(self, corners: [Point]) -> None:
        """ Create Square self with vertices corners.
        Assume all sides are equal and corners are square.
        Extended from Shape.
        >>> s = Square([Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 0)])
        """
        Shape.__init__(self, corners)

    def _set_area(self)->None:
        """
        Set Square self's area.
        Overrides Shape._set_area

        >>> 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)])
