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 DIVIDE = 5;
|
||||
private static final int MODULO = 6;
|
||||
private static final int POWER = 7;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -128,6 +129,11 @@ public class MainActivity extends AppCompatActivity {
|
|||
lastKey = EQUALS;
|
||||
}
|
||||
|
||||
@OnClick(R.id.btn_power)
|
||||
public void powerClicked() {
|
||||
handleOperation(POWER);
|
||||
}
|
||||
|
||||
public void decimalClicked() {
|
||||
String value = getDisplayedNumber();
|
||||
if (!value.contains("."))
|
||||
|
@ -164,6 +170,9 @@ public class MainActivity extends AppCompatActivity {
|
|||
case MODULO:
|
||||
moduloNumbers();
|
||||
break;
|
||||
case POWER:
|
||||
updateResult(Math.pow(baseValue, secondValue));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue