"""
declare a point class
"""


class Point:
    """ A two dimensional point with x and y coordinates

    === Attributes ===
    @type x: float
        horizontal coordinate
    @type y: float
        vertical coordinate
    """

    def __init__(self, x, y):
        """ Create a new Point self with coordinates x and y.
        @type self: Point
        @type x: float | int
        @type y: float | int
        @rtype: None.

        >>> p = Point(3, 4)
        >>> p.x
        3.0
        """
        self.x, self.y = float(x), float(y)

    def __str__(self):
        """ Return a string representation of Point self.

        @type self: Point
            This point
        @rtype: str

        >>> print(Point(3, 4))
        (3.0, 4.0)
        """
        return "({}, {})".format(self.x, self.y)

    def __eq__(self, other):
        """ Return whether self is equivalent to other.
        @type self: Point
        @type other: Point | Any
        @rtype: bool

        >>> p1 = Point(3, 4)
        >>> p2 = Point(6, 8)
        >>> p1 == p1
        True
        >>> p1.__eq__(p2)
        False
        """
        return ((type(self) == type(other)) and
                (self.x == other.x) and (self.y == other.y))

    def distance_to_origin(self):
        """ Return distance from self to (0, 0)

        @type self: Point
        @rtype: float

        >>> p = Point(3, 4)
        >>> p.distance_to_origin()
        5.0
        """
        return (self.x**2 + self.y**2) ** (1 / 2)

    def __add__(self, other_point):
        """ Return vector sum of Points self and other_point.

        @type self: Point
            this point
        @type other_point: Point
            some other 2D point
        @rtype: Point

        >>> print(Point(3, 4) + Point(4, 5))
        (7.0, 9.0)
        >>> print(Point(3, 4) + Point(-3, -4))
        (0.0, 0.0)
        """
        return Point(self.x + other_point.x, self.y + other_point.y)


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