Created
April 21, 2019 04:10
-
-
Save AnasAlmasri/0b875a76cf5f486c4d5da109c1d8f600 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 a number | |
| private int getNumberFromResult(ArrayList<String> results) { | |
| for (String str : results) { | |
| if (getIntNumberFromText(str) != -1) { | |
| return getIntNumberFromText(str); | |
| } | |
| } | |
| return -1; | |
| } | |
| // method to convert string number to integer | |
| private int getIntNumberFromText(String strNum) { | |
| switch (strNum) { | |
| case "zero": | |
| return 0; | |
| case "one": | |
| return 1; | |
| case "two": | |
| return 2; | |
| case "three": | |
| return 3; | |
| case "four": | |
| return 4; | |
| case "five": | |
| return 5; | |
| case "six": | |
| return 6; | |
| case "seven": | |
| return 7; | |
| case "eight": | |
| return 8; | |
| case "nine": | |
| return 9; | |
| } | |
| return -1; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment