mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-06-05 21:49:13 +02:00
implement Root
This commit is contained in:
@ -82,9 +82,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (lastKey == DIGIT) {
|
if (lastKey == DIGIT) {
|
||||||
secondValue = getDisplayedNumberAsDouble();
|
getResult();
|
||||||
calculateResult();
|
|
||||||
baseValue = getDisplayedNumberAsDouble();
|
|
||||||
}
|
}
|
||||||
resetValue = true;
|
resetValue = true;
|
||||||
lastKey = operation;
|
lastKey = operation;
|
||||||
@ -116,6 +114,13 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
handleOperation(MODULO);
|
handleOperation(MODULO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.btn_root)
|
||||||
|
public void rootClicked() {
|
||||||
|
getResult();
|
||||||
|
lastOperation = EQUALS;
|
||||||
|
updateResult(Math.sqrt(baseValue));
|
||||||
|
}
|
||||||
|
|
||||||
@OnClick(R.id.btn_equals)
|
@OnClick(R.id.btn_equals)
|
||||||
public void equalsClicked() {
|
public void equalsClicked() {
|
||||||
if (lastKey == EQUALS)
|
if (lastKey == EQUALS)
|
||||||
@ -153,6 +158,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
baseValue = value;
|
baseValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getResult() {
|
||||||
|
secondValue = getDisplayedNumberAsDouble();
|
||||||
|
calculateResult();
|
||||||
|
baseValue = getDisplayedNumberAsDouble();
|
||||||
|
}
|
||||||
|
|
||||||
private void calculateResult() {
|
private void calculateResult() {
|
||||||
switch (lastOperation) {
|
switch (lastOperation) {
|
||||||
case PLUS:
|
case PLUS:
|
||||||
|
Reference in New Issue
Block a user