Last active
January 18, 2020 07:20
-
-
Save luisenriquecorona/4be7f3e3054b47d642a2dcbf7ab4dea6 to your computer and use it in GitHub Desktop.
Do the variables need a more meaningful context? The function name provides only part of the context; the algorithm provides the rest.
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
private void printGuessStatistics(char candidate, int count) { | |
String number; | |
String verb; | |
String pluralModifier; | |
if (count == 0) { | |
number = "no"; | |
verb = "are"; | |
pluralModifier = "s"; | |
} else if (count == 1) { | |
number = "1"; | |
verb = "is"; | |
pluralModifier = ""; | |
} else { | |
number = Integer.toString(count); | |
verb = "are"; | |
pluralModifier = "s"; | |
} | |
String guessMessage = String.format( | |
"There %s %s %s%s", verb, number, candidate, pluralModifier | |
); | |
print(guessMessage); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment