diff --git a/Java Classes & Interfaces/New Calc Engine/src/MathEquation.java b/Java Classes & Interfaces/New Calc Engine/src/MathEquation.java index f6f17ff..dbe2e3d 100644 --- a/Java Classes & Interfaces/New Calc Engine/src/MathEquation.java +++ b/Java Classes & Interfaces/New Calc Engine/src/MathEquation.java @@ -23,7 +23,7 @@ public class MathEquation { } // Method to execute the calculations - void execute() { + public void execute() { switch (this.opCode) { case 'a': this.result = this.leftVal + this.rightVal; @@ -46,6 +46,22 @@ public class MathEquation { sumOfResults += result; } + public void execute(double leftVal, double rightVal) { + this.leftVal = leftVal; + this.rightVal = rightVal; + + execute(); + } + + public void execute(int leftVal, int rightVal) { + this.leftVal = leftVal; + this.rightVal = rightVal; + + execute(); + + result = (int) result; + } + public static double getAverageResult() { return sumOfResults / numOfCalculations; }