mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
20 lines
413 B
JavaScript
20 lines
413 B
JavaScript
/**
|
|
* 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
|
|
}
|
|
}
|