|
|
@ -23,7 +23,7 @@ public class MathEquation {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Method to execute the calculations
|
|
|
|
// Method to execute the calculations
|
|
|
|
void execute() {
|
|
|
|
public void execute() {
|
|
|
|
switch (this.opCode) {
|
|
|
|
switch (this.opCode) {
|
|
|
|
case 'a':
|
|
|
|
case 'a':
|
|
|
|
this.result = this.leftVal + this.rightVal;
|
|
|
|
this.result = this.leftVal + this.rightVal;
|
|
|
@ -46,6 +46,22 @@ public class MathEquation {
|
|
|
|
sumOfResults += result;
|
|
|
|
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() {
|
|
|
|
public static double getAverageResult() {
|
|
|
|
return sumOfResults / numOfCalculations;
|
|
|
|
return sumOfResults / numOfCalculations;
|
|
|
|
}
|
|
|
|
}
|
|
|
|