Solution 2-6 players: create one constructor for every possible number of players #13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It used to be possible to construct a game with less than two players and with more than six players
however at runtime things did not work out. There was also no validation that the game was in a
playable state. The user had to come up with the idea to call the isPlayable method.
In this version it will not compile for anything other than 2-6 players. The Game class can only be
instantiated it the correct way, and the user gets immediate feedback from the compiler on any
usage errors.
Granted this type of technique becomes awkward when the number of constructors grows big, in those
cases we revert back to a more traditional strategy of runtime validations in the constructor.