Commits

Anonymous committed 6b46f0e

cleaned up comments and refactored function names

Comments (0)

Files changed (1)

src/Phone2Words.java

 	 *            input phone number as an array
 	 * @return all possible words
 	 */
-	public static ArrayList<String> phone2Words(int[] phoneNum) {
+	public static ArrayList<String> telephoneWords(int[] phoneNum) {
 		ArrayList<String> result = new ArrayList<String>();
 
 		for (int i = 0; i < phoneNum.length; i++) {
 		return result;
 	}
 
-	/*
-	 * recursive way to get all combinations of word from a phone
-	 * number
-	 *
-	 * @param phoneNum input phone number as an array
-	 *
-	 * @return all possible words
-	 */
-
 	/**
 	 * recursive way to print all combinations of word from a phone
 	 * number
 	 * @param output
 	 *            output word
 	 */
-	public static void phone2WordsRecursive(int[] phoneNum,
+	public static void telephoneWordsRecursive(int[] phoneNum,
 			int index, char[] output) {
 		if (index == output.length) {
 			System.out.println(output);
 		int currentNum = phoneNum[index];
 		if (isOneOrZero(currentNum)) {
 			output[index] = getCharKey(currentNum, 0);
-			phone2WordsRecursive(phoneNum, index + 1, output);
+			telephoneWordsRecursive(phoneNum, index + 1, output);
 		} else {
 			for (int i = 0; i < 3; i++) {
 				output[index] = getCharKey(currentNum, i);
-				phone2WordsRecursive(phoneNum, index + 1, output);
+				telephoneWordsRecursive(phoneNum, index + 1, output);
 			}
 		}
 	}
 		String expectedResult = "BESTBUY";
 
 		ArrayList<String> result = Phone2Words
-				.phone2Words(phoneNumber);
+				.telephoneWords(phoneNumber);
 
 		int i = 1;
 		for (String str : result) {
 		}
 
 		char[] output = new char[phoneNumber.length];
-		Phone2Words.phone2WordsRecursive(phoneNumber, 0, output);
+		Phone2Words.telephoneWordsRecursive(phoneNumber, 0, output);
 	}
 
 }