in runner/AndroidJunitRunnerSample/app/src/main/java/com/example/android/testing/androidjunitrunnersample/CalculatorActivity.java [87:118]
private void compute(Calculator.Operator operator) {
double operandOne;
double operandTwo;
try {
operandOne = getOperand(mOperandOneEditText);
operandTwo = getOperand(mOperandTwoEditText);
} catch (NumberFormatException nfe) {
Log.e(TAG, "NumberFormatException", nfe);
mResultTextView.setText(getString(R.string.computationError));
return;
}
String result;
switch (operator) {
case ADD:
result = String.valueOf(mCalculator.add(operandOne, operandTwo));
break;
case SUB:
result = String.valueOf(mCalculator.sub(operandOne, operandTwo));
break;
case DIV:
result = String.valueOf(mCalculator.div(operandOne, operandTwo));
break;
case MUL:
result = String.valueOf(mCalculator.mul(operandOne, operandTwo));
break;
default:
result = getString(R.string.computationError);
break;
}
mResultTextView.setText(result);
}