Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict'
- class Point {
- constructor(x, y) {
- this.x = x;
- this.y = y;
- }
- distance(p1, p2) {
- return Math.sqrt(((p2.x - p1.x) ** 2) + ((p2.y = p1.y) ** 2));
- }
- add(a, b) {
- this.x += a;
- this.y += b;
- }
- }
- const point = new Point();
- console.log(point.distance(new Point(5, 7), new Point(17, 24)));
- let point2 = new Point(3, 5);
- console.log(point2.x);
- console.log(point2.y);
- point2.add(3, 3);
- console.log(point2.x);
- console.log(point2.y);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement