Created
April 21, 2019 04:27
-
-
Save AnasAlmasri/3bf166e03625dc40d4083d6f495bc976 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // method to loop through results trying to find an operator | |
| private char getOperatorFromResult(ArrayList<String> results) { | |
| for (String str : results) { | |
| if (getCharOperatorFromText(str) != '0') { | |
| return getCharOperatorFromText(str); | |
| } | |
| } | |
| return '0'; | |
| } | |
| // method to convert string operator to char | |
| private char getCharOperatorFromText(String strOper) { | |
| switch (strOper) { | |
| case "plus": | |
| case "add": | |
| return '+'; | |
| case "minus": | |
| case "subtract": | |
| return '-'; | |
| case "times": | |
| case "multiply": | |
| return '*'; | |
| case "divided by": | |
| case "divide": | |
| return '/'; | |
| case "power": | |
| case "raised to": | |
| return '^'; | |
| } | |
| return '0'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment