Skip to content

Commit

Permalink
Validation Fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishal1297 committed Oct 18, 2020
1 parent 4c7b8c0 commit 83eeb5e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions app/src/main/java/com/app/calculator/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ public void onClick(View view) {
return;
}
Expression expression = new Expression(exp + "/100");
resultTxtView.setText(String.valueOf(expression.calculate()));
String result = String.valueOf(expression.calculate());
expTxtView.setText(result);
resultTxtView.setText(result);
} else if (R.id.dot == id) {
generateExpression(".");
}
Expand All @@ -141,13 +143,14 @@ public void onClick(View view) {
private void calculate() {
String exp = expTxtView.getText().toString();
String result;
if (!exp.equals("") && !exp.equals(".") && !exp.equals("0")) {
expTxtView.setText("");
Expression expression = new Expression(exp);
result = String.valueOf(expression.calculate());
resultTxtView.setText(result);
expTxtView.setText(result);
if (exp.equals("") || exp.equals(".") || isSpecialChar("" + exp.charAt(exp.length() - 1))) {
return;
}
expTxtView.setText("");
Expression expression = new Expression(exp);
result = String.valueOf(expression.calculate());
resultTxtView.setText(result);
expTxtView.setText(result);
}

public void generateExpression(String val) {
Expand Down
Binary file modified app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 83eeb5e

Please sign in to comment.