2 ms·
No, that refactored version is indeed supposed to be used like print(new GuessStatisticsMessage().make(candidate, count)); There are cases where using a c
by Joker_vD 2y ago
No, that refactored version is indeed supposed to be used like
print(new GuessStatisticsMessage().make(candidate, count));
There are cases where using a class as a bag of pseudo-global variables that get mutated during a long web of internal method calls — a recursive-descent parser for a non-trival language is a prime example, — is fine but this, I'd argue, is not one of those cases. You need to (very straightforwardly) map two input values to three output values and return them glued together — one function with a switch in it is quite enough for that.
P.S. And what the hell does "thereAreNoLetters" even mean? Oh, right, it makes sense since this is a letter-guessing game, and this class is used to tell you that no, there are no letters like the one you tried to guess. Bleh.