Last active
March 31, 2019 20:33
-
-
Save knappologi/d40d1f52bf824eb23d444ff82cea13ad to your computer and use it in GitHub Desktop.
CatNameGenerator
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
| // 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