Skip to content

Instantly share code, notes, and snippets.

@khunzohn
Created June 24, 2017 15:23
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 khunzohn/cfa54b3d469d3d99f253d2e85e5281bb to your computer and use it in GitHub Desktop.
Save khunzohn/cfa54b3d469d3d99f253d2e85e5281bb to your computer and use it in GitHub Desktop.
public class DigitMapper {
public DigitMapper() {
}
public String mapToWord(int digit) throws DigitRangeException {
if (digit < 0 || digit > 9) throw new DigitRangeException();
switch (digit) {
case 0:
return "Zero";
case 1:
return "One";
// case 2,3,...9
default:
return "";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment