3 ms·
I ask them to design a structure for a card games that uses a standard deck of playing cards, and how they would implement shuffle (not the algorithm itself) an
by joeld42 10y ago
I ask them to design a structure for a card games that uses a standard deck of playing cards, and how they would implement shuffle (not the algorithm itself) and dealing and hands. This is simple. People manage to grossly over engineer it.
My ideal response would be one struct with nothing but a suit enum and int value. A deck is just an array of these, as is a hand. But usually people start with a deck class, then try to reuse that for the hand, discard pile, etc. Things get complicated quickly, just like in real world problems, and a good architect can keep that in check while still providing useful abstractions.