From 4caefe42ee97a8035515906472483e6296b28614 Mon Sep 17 00:00:00 2001 From: Mohammed Date: Tue, 5 Feb 2019 14:48:41 +0300 Subject: [PATCH] it complete , but the formula for some answers .. i dont know if it correct or not. But it work fine with that formula i use. --- geom.js | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 4 deletions(-) diff --git a/geom.js b/geom.js index d942747..e9d6813 100644 --- a/geom.js +++ b/geom.js @@ -1,27 +1,96 @@ +//class Rectangle { +//constructor(length, width) { +//this.length = length; +//this.width = width; +//} +//} + class Rectangle { - constructor(length, width) { - this.length = length; + constructor(height, width) { + this.height = height; this.width = width; } + + isSquare() { + if (this.height === this.width) { + return true; + } + } + area() { + console.log("The area is " + (this.height * this.width)); + } + + perimeter() { + console.log("The Perimeter is " + ((2 * this.height) + (2 * this.width))); + } } +//class Triangle { +//constructor(sideA, sideB, sideC){ +//this.sideA = sideA; +//this.sideB = sideB; +//this.sideC = sideC; +//} +//} + class Triangle { - constructor(sideA, sideB, sideC){ + constructor(sideA, sideB, sideC) { this.sideA = sideA; this.sideB = sideB; this.sideC = sideC; } + + isEquilateral() { + if (this.sideA === this.sideB && this.sideA === this.sideC && this.sideB === this.sideC) { + return true; + } + } + isIsosceles() { + if (this.sideA === this.sideB || this.sideA === this.sideC || this.sideB === sideC) { + return true; + } + } + area() { + let p = (this.sideA + this.sideB + this.sideC) / 2 + let area = (Math.sqrt(p * ((p - this.sideA) * (p - this.sideB) * (p - this.sideC)))) + console.log("The Area is " + area); + } + isObtuse() { + if ((this.sideA * this.sideA) + (this.sideB * this.sideB) > (this.sideC * this.sideC) || (this.sideA * this.sideA) + (this.sideC * this.sideC) > (this.sideB * this.sideB) || (this.sideC * this.sideC) + (this.sideB * this.sideB) > (this.sideA * this.sideA)) { + return true; + } + } + } +//class LineSegment { +//constructor(x1, y1, x2, y2) { +// this.x1 = x1; +//this.y1 = y1; +//this.x2 = x2; +//this.y2 = y2; +//} +//} + class LineSegment { - constructor(x1, y1, x2, y2){ + constructor(x1, y1, x2, y2) { this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; } + + + cal() { + let point1 = ((this.x1 + this.x2) / 2); + let point2 = ((this.y1 + this.y2) / 2); + let res = (point1 - point2) + + console.log('The length is ' + res); + + } } // NOTE: DO NOT REMOVE OR ALTER