Beats 90% ( Runtime )
Beats 90% ( Runtime )\n Describe your first thoughts on how to solve this problem. \n\n\n# Code\n\nclass Calculator {\n    n : number;\n    \n    constructor(va
# Beats 90% ( Runtime )\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n\n# Code\n```\nclass Calculator {\n    n : number;\n    \n    constructor(value: number) {\n        this.n = value;\n    }\n    \n    add(value: number): Calculator {\n        this.n += value;\n        return this\n    }\n    \n    subtract(value: number): Calculator {\n        this.n -= value;\n        return this\n    }\n    \n    multiply(value: number): Calculator {\n        this.n *= value;\n        return this\n    }\n    \n    divide(value: number): Calculator {\n        if(value === 0) throw Error("Division by zero is not allowed");\n        this.n /= value;\n        return this\n    }\n    \n    power(value: number): Calculator {\n        this.n = Math.pow(this.n, value)\n        return this\n    }\n    \n    getResult(): number {\n        return this.n\n    }\n}\n```
['TypeScript']