mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-02-17 20:10:40 +01:00
implement Power(x, y)
This commit is contained in:
parent
08dccc68ba
commit
0e216ad692
@ -25,6 +25,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
private static final int MULTIPLY = 4;
|
private static final int MULTIPLY = 4;
|
||||||
private static final int DIVIDE = 5;
|
private static final int DIVIDE = 5;
|
||||||
private static final int MODULO = 6;
|
private static final int MODULO = 6;
|
||||||
|
private static final int POWER = 7;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -128,6 +129,11 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
lastKey = EQUALS;
|
lastKey = EQUALS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnClick(R.id.btn_power)
|
||||||
|
public void powerClicked() {
|
||||||
|
handleOperation(POWER);
|
||||||
|
}
|
||||||
|
|
||||||
public void decimalClicked() {
|
public void decimalClicked() {
|
||||||
String value = getDisplayedNumber();
|
String value = getDisplayedNumber();
|
||||||
if (!value.contains("."))
|
if (!value.contains("."))
|
||||||
@ -164,6 +170,9 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
case MODULO:
|
case MODULO:
|
||||||
moduloNumbers();
|
moduloNumbers();
|
||||||
break;
|
break;
|
||||||
|
case POWER:
|
||||||
|
updateResult(Math.pow(baseValue, secondValue));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user