class position { #x; #y; constructor(x = 0, y = 0) { this.x = x; this.y = y; } set x(target) { if (typeof(target) !== "number") { throw new TypeError("X cord must be an number."); } this.#x = target; } set y(target) { if (typeof(target) !== "number") { throw new TypeError("Y cord must be an number."); } this.#y = target; } get x() { return this.#x; } get y() { return this.#y; } compare(target) { if (!(target instanceof position)) { throw new TypeError("Can only compare position with position."); } const result = new position(); result.x = target.x - this.x; result.y = target.y - this.y; return result; } } export { position };