Skip to content

Instantly share code, notes, and snippets.

@knappologi
Last active March 31, 2019 20:33
Show Gist options
  • Select an option

  • Save knappologi/d40d1f52bf824eb23d444ff82cea13ad to your computer and use it in GitHub Desktop.

Select an option

Save knappologi/d40d1f52bf824eb23d444ff82cea13ad to your computer and use it in GitHub Desktop.
CatNameGenerator
// Generate a new cat name for your cat, based on its favorite food!
public static String catNameGenerator(String catsFavoriteFood) {
String[] catTitle = {"Mister/Miss/Mrs", "Lord", "Big", "Little", "King/Queen", "Captain", "Doctor", "Kitty", "Sweet", "Senior"};
String [] cuteNames = {"Pumpkin", "Steve", "Jellybean", "Monster", "Summer", "(of) Doom", "(of) Dreams", "Kibble", "Cinnamon"};
if (catsFavoriteFood.equals(null) || catsFavoriteFood.isEmpty()) {
return "Mister/Miss/Mrs Fluffypaw";
}
if (catsFavoriteFood.length() < 3) {
return "Captain Whiskers";
} else {
int titleCount = 0;
int nameCount = catsFavoriteFood.length() / 2;
if (catsFavoriteFood.contains("a") || catsFavoriteFood.contains("o")) {
nameCount += 1;
}
while (titleCount != catsFavoriteFood.length()) {
titleCount++;
}
String title = catTitle[titleCount % 10];
String name = cuteNames[nameCount % 10];
return title + " " + name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment