Skip to content

Instantly share code, notes, and snippets.

@spilth
Created May 23, 2011 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spilth/986830 to your computer and use it in GitHub Desktop.
Save spilth/986830 to your computer and use it in GitHub Desktop.
Translate Function Before
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