class Point{
x = 0;
y = 0;
constructor(x,y) {
this.x = x;
this.y = y;
}
getDistance(other) {
let xDis = Math.abs(this.x - other.x);
let yDis = Math.abs(this.y - other.y);
return Math.sqrt(xDis*xDis + yDis*yDis);
}
}
let point = new Point(1,1)
let point2 = new Point(0,0)
console.log(point.getDistance(point2));
class TPoint{
x:number = 0;
y:number = 0;
constructor(x:number,y:number) {
this.x = x;
this.y = y;
}
getDistance(other:TPoint):number {
let xDis = Math.abs(this.x - other.x);
let yDis = Math.abs(this.y - other.y);
return Math.sqrt(xDis*xDis + yDis*yDis);
}
}
let tpoint:TPoint = new TPoint(1,1)
let tpoint2:TPoint = new TPoint(3,3)
console.log(tpoint.getDistance(tpoint2));