"content":"<p>Design a <code>Calculator</code> class. The class should provide the mathematical operations of addition, subtraction, multiplication, division, and exponentiation. It should also allow consecutive operations to be performed using method chaining. The <code>Calculator</code> class constructor should accept a number which serves as the initial value of <code>result</code>.</p>\n\n<p>Your <font face=\"monospace\"><code>Calculator</code> </font>class should have the following methods:</p>\n\n<ul>\n\t<li><code>add</code> - This method adds the given number <code>value</code> to the <code>result</code> and returns the updated <code>Calculator</code>.</li>\n\t<li><code>subtract</code> - This method subtracts the given number <code>value</code> from the <code>result</code> and returns the updated <code>Calculator</code>.</li>\n\t<li><code>multiply</code> - This method multiplies the <code>result</code> by the given number <code>value</code> and returns the updated <code>Calculator</code>.</li>\n\t<li><code>divide</code> - This method divides the <code>result</code> by the given number <code>value</code> and returns the updated <code>Calculator</code>. If the passed value is <code>0</code>, an error <code>"Division by zero is not allowed"</code> should be thrown.</li>\n\t<li><code>power</code> - This method raises the <code>result</code> to the power of the given number <code>value</code> and returns the updated <code>Calculator</code>.</li>\n\t<li><code>getResult</code> - This method returns the <code>result</code>.</li>\n</ul>\n\n<p>Solutions within <code>10<sup>-5</sup></code> of the actual result are considered correct.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nactions = ["Calculator", "add", "subtract", "getResult"], \nvalues = [10, 5, 7]\n<strong>Output:</strong> 8\n<strong>Explanation:</strong> \nnew Calculator(10).add(5).subtract(7).getResult() // 10 + 5 - 7 = 8\n</pre>\n\n<p><strong class=\"example\">Example 2:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nactions = ["Calculator", "multiply", "power", "getResult"], \nvalues = [2, 5, 2]\n<strong>Output:</strong> 100\n<strong>Explanation:</strong> \nnew Calculator(2).multiply(5).power(2).getResult() // (2 * 5) ^ 2 = 100\n</pre>\n\n<p><strong class=\"example\">Example 3:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nactions = ["Calculator", "divide", "getResult"], \nvalues = [20, 0]\n<strong>Output:</strong> "Division by zero is not allowed"\n<strong>Explanation:</strong> \nnew Calculator(20).divide(0).getResult() // 20 / 0 \n\nThe error should be thrown because we cannot divide by zero.\n</pre>\n\n<p> </p>\n<p><strong>Constraints:</strong></p>\n\n<ul>\n\t<li><code>actions</code> is a valid JSON array of strings</li>\n\t<li><code>values</code> is a valid JSON array of numbers</li>\n\t<li><code>2 <= actions.length <= 2 * 10<sup>4</sup></code></li>\n\t<li><code>1 <= values.length <= 2 * 10<sup>4</sup> - 1</code></li>\n\t<li><code>actions[i]</code> is one of "Calculator", "add", "subtract", "multiply", "divide", "power", and "getResult"</li>\n\t<li>First action is always "Calculator"</li>\n\t<li>Last action is always "getResult"</li>\n</ul>\n",