# point.py
#
# ICS 33 Spring 2026
# Code Example
#
# A class that briefly demonstrates the use of the @classmethod decorator
# to provide a factory method.


class Point:
    @classmethod
    def from_cartesian(cls, x, y):
        # Since cls is the class we've called from_cartesian on, we can call
        # it like a function and build an object of that type.  In this case,
        # we expect that type to be Point, so we expect the line below to
        # create a new Point object and initialize its x and y coordinates
        # accordingly.
        return cls(x, y)


    def __init__(self, x, y):
        self._x = x
        self._y = y


    def x(self):
        return self._x


    def y(self):
        return self._y
