"""
Exercise 3: class methods, static methods, and __slots__

Implement class Vector with:
  __slots__ = ("x", "y")     -- no per-instance __dict__ allowed
  __init__(self, x, y)
  __add__(self, other)        -> new Vector, componentwise sum
  __repr__(self)               -> "Vector(x, y)"
  @classmethod zero(cls)        -> Vector(0, 0), an alternative constructor
  @staticmethod dot(a, b)        -> a.x*b.x + a.y*b.y (no self/cls used)

Because of __slots__, assigning any attribute not in ("x", "y") must
raise AttributeError.
"""

class Vector:
    __slots__ = ("x", "y")

    def __init__(self, x, y):
        # TODO
        pass

    def __add__(self, other):
        # TODO
        pass

    def __repr__(self):
        # TODO
        pass

    @classmethod
    def zero(cls):
        # TODO
        pass

    @staticmethod
    def dot(a, b):
        # TODO
        pass


# --- self-check: do not modify below this line ---
v1 = Vector(1, 2)
v2 = Vector(3, 4)

checks = [
    (repr(v1 + v2), "Vector(4, 6)"),
    (repr(Vector.zero()), "Vector(0, 0)"),
    (Vector.dot(v1, v2), 11),  # 1*3 + 2*4
]

try:
    v1.z = 99
    slots_enforced = False
except AttributeError:
    slots_enforced = True
checks.append((slots_enforced, True))

all_passed = all(actual == expected for actual, expected in checks)
for actual, expected in checks:
    print(f"got {actual!r}, expected {expected!r} -> {'PASS' if actual == expected else 'FAIL'}")

print("ALL PASS" if all_passed else "SOME FAILED")
