implement Power(x, y)

This commit is contained in:
tibbi 2015-12-26 14:04:45 +01:00
parent 08dccc68ba
commit 0e216ad692
1 changed files with 9 additions and 0 deletions

View File

@ -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;
}