class Circle extends Shape {
#Constructor
constructor (radius) {
this.radius = radius
}
#method
getArea () {
return Math.PI *2 *this.radius
}
#Call the superclass method
expand(n) {
return super.expand(n) *Math.PI
}
#Static methods
static createFromDiameter(diameter) {
return new Circle(diameter /2)
}
Syntactic sugar for prototypes. See: classes
Comments