From ff3d681f57372f912bc6d40e6c03efd2d297b223 Mon Sep 17 00:00:00 2001 From: officeraboda7m Date: Mon, 4 Feb 2019 19:49:01 +0300 Subject: [PATCH] homework --- geom.js | 83 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 65 insertions(+), 18 deletions(-) diff --git a/geom.js b/geom.js index d942747..77c4ce9 100644 --- a/geom.js +++ b/geom.js @@ -1,32 +1,79 @@ class Rectangle { - constructor(length, width) { - this.length = length; - this.width = width; - } +constructor(length, width) { +this.length = length; +this.width = width; +} + +isSquare() { +if (this.length===this.width) { +return true; +} +} + +calcArea() { +return this.length*this.width; +} + +clacPerimeter() { +return (2*this.length)+(2*this.width); +} + } class Triangle { - constructor(sideA, sideB, sideC){ - this.sideA = sideA; - this.sideB = sideB; - this.sideC = sideC; - } + +constructor(sideA, sideB, sideC){ +this.sideA = sideA; +this.sideB = sideB; +this.sideC = sideC; +} + +isEquilateral() { +if (sideA===sideB===sideC) { +return true; +} +} + +isIsosceles() { +if (sideA===sideC) { +return true; +} +} + +calcArea() { +s = (this.sideA+this.sideB+this.sideC)/2; +math.sqrt(s(s-this.sideA)(s-this.sideB)(s-this.sideC)) +} + +isObtuse() { +if ((this.sideC>this.sideA)&&(this.sideC>this.sideB)) { +return true; +} +} + } class LineSegment { - constructor(x1, y1, x2, y2){ - this.x1 = x1; - this.y1 = y1; - this.x2 = x2; - this.y2 = y2; - } + +constructor(x1, y1, x2, y2){ +this.x1 = x1; +this.y1 = y1; +this.x2 = x2; +this.y2 = y2; +} + +calcDist() { +return math.sqrt((this.x2-this.x1)*(this.x2-this.x1)+(this.y2-this.y1)*(this.y2-this.y1)); +} + } // NOTE: DO NOT REMOVE OR ALTER module.exports = { - Rectangle: Rectangle, - Triangle: Triangle, - LineSegment: LineSegment +Rectangle: Rectangle, +Triangle: Triangle, +LineSegment: LineSegment } +