SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict'
  2.  
  3. class Point {
  4.   constructor(x, y) {
  5.     this.x = x;
  6.     this.y = y;
  7.   }
  8.   distance(p1, p2) {
  9.     return Math.sqrt(((p2.x - p1.x) ** 2) + ((p2.y = p1.y) ** 2));
  10.   }
  11.   add(a, b) {
  12.     this.x += a;
  13.     this.y += b;
  14.   }
  15. }
  16.  
  17. const point = new Point();
  18. console.log(point.distance(new Point(5, 7), new Point(17, 24)));
  19. let point2 = new Point(3, 5);
  20. console.log(point2.x);
  21. console.log(point2.y);
  22. point2.add(3, 3);
  23. console.log(point2.x);
  24. console.log(point2.y);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top