Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions geom.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ class Rectangle {
this.length = length;
this.width = width;
}

isSquare(){
if(this.length === this.width ){
return true;
}
}

calculateArea(){
let area = this.length*this.width;
return area;
}
calculatePerimeter(){
let perimeter = 2*(this.length+this.width);
return perimeter;
}
}


Expand All @@ -12,6 +27,39 @@ class Triangle {
this.sideB = sideB;
this.sideC = sideC;
}

// Equilateral Triangle:
// All three sides have equal length
// All three angles are equal to 60 degrees
isEquilateral() {
if(this.sideA === this.sideB && this.sideB === this.sideC){
return true;
}
}
//has two equal sides
isIsosceles(){
if(this.sideA === this.sideB) {
return true;
}
}

//Heron's Formula
// I used Math.sqrt() to find the square root
area(){
let s = (this.sideA + this.sideB + this.sideB)/2
let area = s*(s-this.sideA)*(s-this.sideB)*(s-this.sideC);
return Math.sqrt(area);
}

isObtuse(){
let a = Math.pow(this.sideA,2);
let b = Math.pow(this.sideB,2);
let c = Math.pow(this.sideC,2);
if(c > a+b ){
return true;
}
}

}


Expand All @@ -22,6 +70,15 @@ class LineSegment {
this.x2 = x2;
this.y2 = y2;
}

calculateLength(){
x1 = this.x1;
x2 = this.x2;
x3 = this.x3;
x4 = this.x4;
let length = Math.sqrt(Math.pow(x2-x1,2) + Math.pow(y2-y1,2));
return length;
}
}

// NOTE: DO NOT REMOVE OR ALTER
Expand Down