implement Root
This commit is contained in:
parent
0e216ad692
commit
aa6ebd00b3
|
@ -82,9 +82,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
return;
|
||||
|
||||
if (lastKey == DIGIT) {
|
||||
secondValue = getDisplayedNumberAsDouble();
|
||||
calculateResult();
|
||||
baseValue = getDisplayedNumberAsDouble();
|
||||
getResult();
|
||||
}
|
||||
resetValue = true;
|
||||
lastKey = operation;
|
||||
|
@ -116,6 +114,13 @@ public class MainActivity extends AppCompatActivity {
|
|||
handleOperation(MODULO);
|
||||
}
|
||||
|
||||
@OnClick(R.id.btn_root)
|
||||
public void rootClicked() {
|
||||
getResult();
|
||||
lastOperation = EQUALS;
|
||||
updateResult(Math.sqrt(baseValue));
|
||||
}
|
||||
|
||||
@OnClick(R.id.btn_equals)
|
||||
public void equalsClicked() {
|
||||
if (lastKey == EQUALS)
|
||||
|
@ -153,6 +158,12 @@ public class MainActivity extends AppCompatActivity {
|
|||
baseValue = value;
|
||||
}
|
||||
|
||||
private void getResult() {
|
||||
secondValue = getDisplayedNumberAsDouble();
|
||||
calculateResult();
|
||||
baseValue = getDisplayedNumberAsDouble();
|
||||
}
|
||||
|
||||
private void calculateResult() {
|
||||
switch (lastOperation) {
|
||||
case PLUS:
|
||||
|
|
Loading…
Reference in New Issue