"""
Module for various shapes.
"""
from turtle import Turtle
from point import Point


class Square:
    """
    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):
        """ Create a new Square self with corners.

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

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


    def move_by(self, offset_point):
        """
        Move Square self to a new position by adding Point offset_point to
        each corner.

        @type self: Square
        @type offset_point: Point
        @rtype: None
        """
        self.corners = [c + offset_point for c in self.corners]
        # equivalent to...
        # new_corners = []
        # for c in self.corners:
        #    new_corners.append(c + offset_point)
        # self.corners = new_corners

    def draw(self):
        """
        Draw Square self.

        @type self: Square
        @rtype: None
        """
        self._turtle.penup()
        self._turtle.goto(self.corners[-1].x, self.corners[-1].y)
        self._turtle.pendown()
        for i in range(len(self.corners)):
            self._turtle.goto(self.corners[i].x, self.corners[i].y)

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

    s = Square([Point(0, 0), Point(100, 0), Point(100, 100), Point(0, 100)])
    s.draw()
    s.move_by(Point(100,150))
    # s.area = 1000 # ==> will produce an exception - not allowed to set area