Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I made it except LineSegment and I faced problems with pull requsrt s… #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
84 changes: 81 additions & 3 deletions geom.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,37 @@ class Rectangle {
this.length = length;
this.width = width;
}
}
perimeter() {
return ((this.length + this.width) * 2);
}


area(){
return this.length * this.width
}
isSquare() {
if(this.length === this.width){
return true;
}
else{
return false;
}
}
}
rectangle1 = new Rectangle(11,11);
rectangle1.isSquare();
rectangle1.area();
rectangle1.perimeter();

rectangle2 = new Rectangle(1,51);
rectangle2.isSquare();
rectangle2.area();
rectangle2.perimeter();

rectangle3 = new Rectangle(4,8);
rectangle3.isSquare();
rectangle3.area();
rectangle3.perimeter();


class Triangle {
Expand All @@ -12,8 +42,47 @@ class Triangle {
this.sideB = sideB;
this.sideC = sideC;
}
}
isEquilateral(){
if(this.sideA === this.sideB && this.sideA === this.sideC )
{

console.log("sorry ,this calculater is not for Equilateral Triangle");
return true;
}
else{
console.log("you can use this calculater");
return false;
}
}
isIsosceles(){
if((this.sideA === this.sideB && this.sideA !== this.sideC) || (this.sideC === this.sideB && this.sideA !== this.sideB) ){
return true;
}
else{
return false;
}
}

isObtuse() { // this function dont work , always return falls

if(((this.sideA *2)+(this.sideB *2) === (this.sideC *2))||((this.sideB *2)+(this.sideC *2) === this.sideA *2) ||((this.sideA *2)+(this.sideC *2) === this.sideB *2)) {
return true
}
else {
return false;
}
}


area() {
return ((this.sideA + this.sideB + this.sideC) * 0.5);
}


}
triangle1 = new Triangle(20,20,20) //after googleing I found out if the tringle is Equilateral Triangle , it will have diffrant way to calculate
triangle1.isEquilateral();
triangle1.area();

class LineSegment {
constructor(x1, y1, x2, y2){
Expand All @@ -22,8 +91,17 @@ class LineSegment {
this.x2 = x2;
this.y2 = y2;
}
length(){
for( var x = this.x1 ; x >= this.x2 ; x++){
this.length = x;
}
for(var y = this.y1 ; y >= this.y2 ; y++){
this.length = y;
}
}
}

let line = new LineSegment(2,3,14,10)
line.length();
// NOTE: DO NOT REMOVE OR ALTER
module.exports = {
Rectangle: Rectangle,
Expand Down