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
83 changes: 65 additions & 18 deletions geom.js
Original file line number Diff line number Diff line change
@@ -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
}