forked from TheAlgorithms/JavaScript
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCone.js
More file actions
Latest commit
30 lines (27 loc) · 736 Bytes
/
Copy pathCone.js
File metadata and controls
30 lines (27 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* This class represents a circular cone and can calculate its volume and surface area
* https://en.wikipedia.org/wiki/Cone
* @constructor
* @param {number} baseRadius - The radius of the base of the cone.
* @param {number} height - The height of the cone
*/
exportdefaultclassCone{
constructor(baseRadius,height){
this.baseRadius=baseRadius
this.height=height
}
baseArea=()=>{
returnMath.pow(this.baseRadius,2)*Math.PI
}
volume=()=>{
return(this.baseArea()*this.height*1)/3
}
surfaceArea=()=>{
return(
this.baseArea()+
Math.PI*
this.baseRadius*
Math.sqrt(Math.pow(this.baseRadius,2)+Math.pow(this.height,2))
)
}
}