Files
codeql/javascript/ql/test/library-tests/Classes/points.js
2018-08-02 17:53:23 +01:00

34 lines
499 B
JavaScript

class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
get dist() {
return Math.sqrt(this.x*this.x+this.y*this.y);
}
toString() {
return "(" + this.x + ", " + this.y + ")";
}
static className() {
return "Point";
}
}
class ColouredPoint extends Point {
constructor(x, y, colour) {
super(x, y);
this.colour = c;
}
toString() {
return super.toString() + " in " + this.colour;
}
static className() {
return "ColouredPoint";
}
}