-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProperties.js
36 lines (36 loc) · 941 Bytes
/
Properties.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var Point = /** @class */ (function () {
function Point(_x, _y) {
this._x = _x;
this._y = _y;
}
Point.prototype.draw = function () {
console.log("X: " + this._x + ", Y: " + this._y);
};
Point.prototype.getX = function () {
return this.x;
};
Point.prototype.setX = function (value) {
if (value < 0)
throw new Error("value cannot be less than 0");
this._x = value;
};
Object.defineProperty(Point.prototype, "x", {
get: function () {
return this._x;
},
set: function (value) {
if (value < 0)
throw new Error("value cannot be less than 0");
this._x = value;
},
enumerable: false,
configurable: true
});
return Point;
}());
var point = new Point(1, 2);
// let x = point.getX();
// point.setX(10);
var x = point.x;
point.x = 10;
point.draw();