Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //nodejs v4.2.6
- 'use strict';
- class Point {
- constructor (x, y) {
- this.x = x;
- this.y = y;
- }
- length (point) {
- console.log(point);
- return Math.sqrt (Math.pow(this.x - point.x, 2) + Math.pow(this.y - point.y, 2));
- }
- }
- class Triangle {
- constructor (p1,p2,p3) {
- this.p1 = p1;
- this.p2 = p2;
- this.p3 = p3;
- }
- calcPerimeter () {
- let length1 = this.p1.length (this.p2);
- let length2 = this.p2.length (this.p2);
- let length3 = this.p1.length (this.p3);
- return length1 + length2 + length3;
- }
- }
- let p1 = new Point (1,1);
- let p2 = new Point (2,2);
- let p3 = new Point (3,3);
- let triangle = new Triangle (p1,p2,p3);
- console.log(triangle.calcPerimeter());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement