diff --git a/geom.js b/geom.js index d942747..d5da428 100644 --- a/geom.js +++ b/geom.js @@ -3,15 +3,44 @@ class Rectangle { this.length = length; this.width = width; } + isSquare() { + return this.length === this.width ; + } + area(){ + return this.length*this.width + } + perimeter(){ + return 2*this.length + this.width*2 + } } + class Triangle { constructor(sideA, sideB, sideC){ this.sideA = sideA; this.sideB = sideB; this.sideC = sideC; } + isEquilateral(){ + return this.sideA === this.sideB === this.sideC ; + } + isIsosceles(){ + return this.sideA === this.sideB || this.sideB === this.sideC || this.sideA === this.sideC ; + } + area(){ + let a = (sideA+ sideB + sideC)/2; +let area = Math.sqrt(a*((a-this.sideA)*(a-this.sideB)*(a-this.sideC))); +console.log(area) ; + } + Obtuse(){ + return this.sideA === this.sideB && this.sideA !== this.sideC || + this.sideA === this.sideB && this.sideB !== this.sideC || + this.sideA === this.sideC && this.sideA !== this.sideB || + this.sideA === this.sideC && this.sideC !== this.sideB || + this.sideB === this.sideC && this.sideC !== this.sideA || + this.sideB === this.sideC && this.sideB !== this.sideA + } } @@ -22,6 +51,9 @@ class LineSegment { this.x2 = x2; this.y2 = y2; } + LineSegment(){ + return (this.y2 - this.y1) / (this.x2 - this.x1); + } } // NOTE: DO NOT REMOVE OR ALTER @@ -30,3 +62,5 @@ module.exports = { Triangle: Triangle, LineSegment: LineSegment } + + diff --git a/spec/geometry_spec.js b/spec/geometry_spec.js index f539663..b240046 100644 --- a/spec/geometry_spec.js +++ b/spec/geometry_spec.js @@ -3,7 +3,7 @@ var Rectangle = Geom.Rectangle; var Triangle = Geom.Triangle; var LineSegment = Geom.LineSegment; -describe('Rectangle', function() { +describe('Rectangle', function(height, width) { it('is a class that is defined', function () { expect(Rectangle).toBeDefined() }) @@ -80,3 +80,32 @@ describe('LineSegment', function() { expect(line.length()).toEqual(5); }); }); + + +var y = 0 ; +var x = 0 ; +class ATM { + constructor (type, money , transactionHistory ){ + this.type=type; + this.money= money ; + this.transactionHistory = transactionHistory + + + } + withdraw() { + + this.money = this.money-1 ; + x-- ; + } + deposit(){ + this.money=this.money+1 + y++ ; +} +showBalance(){ + consol.log(this.money) +} +transaction(){ + console.log(" Increased by " + y + " Decreased by " + x ) + +} +}