algorithm class: circle (#1252)

This commit is contained in:
Gustavo Kamihara
2022-10-31 13:02:35 -03:00
committed by GitHub
parent f1ef64cc2d
commit 7256e5313f
2 changed files with 30 additions and 0 deletions

19
Geometry/Circle.js Normal file
View File

@ -0,0 +1,19 @@
/**
* This class represents a circle and can calculate it's perimeter and area
* https://en.wikipedia.org/wiki/Circle
* @constructor
* @param {number} radius - The radius of the circule.
*/
export default class Circle {
constructor (radius) {
this.radius = radius
}
perimeter = () => {
return this.radius * 2 * Math.PI
}
area = () => {
return Math.pow(this.radius, 2) * Math.PI
}
}