Created
May 23, 2011 15:00
-
-
Save spilth/986830 to your computer and use it in GitHub Desktop.
Translate Function Before
This file contains 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
public String translate(String input) { | |
Character firstLetter = input.charAt(0); | |
String newString; | |
if (isVowel(firstLetter)) { | |
newString = input + "way"; | |
} else { | |
int splitIndex = findSplitIndex(input); | |
String newFirstHalf = input.substring(splitIndex); | |
String newSecondHalf = input.substring(0,splitIndex).toLowerCase(); | |
Character newFirstLetter = newFirstHalf.charAt(0); | |
if (Character.isUpperCase(firstLetter)) { | |
newFirstLetter = Character.toUpperCase(newFirstLetter); | |
} | |
newString = newFirstLetter + newFirstHalf.substring(1) + newSecondHalf + "ay"; | |
} | |
return newString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment