Created
December 26, 2017 20:50
-
-
Save sigmadeltasoftware/e22c5ce6d1b30725cc4b11eac2e1715c to your computer and use it in GitHub Desktop.
IAA_2: GreetingsRepository good
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 enum GreetingsLanguage { | |
FRENCH("Bonjour "), | |
ENGLISH("Hello "), | |
DUTCH("Hallo "); | |
private String _greeting; | |
GreetingsLanguage(String greeting) { | |
_greeting = greeting; | |
} | |
public String getGreeting() { | |
return _greeting; | |
} | |
} |
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 class GreetingsRepository { | |
private static final String TAG = "GreetingsRepository"; | |
public String getGreeting(String name, GreetingsLanguage language) throws IllegalArgumentException { | |
if (name == null || name.equals("")) { | |
final String err = "name: " + name + " is invalid!"; | |
Log.e(TAG, err); | |
throw new IllegalArgumentException(err); | |
} | |
return language.getGreeting() + name + "!"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment