Open pnikolov opened 1 year ago
Correct. This is the thing I spent the most time on and implemented several times. Originally, the suits were part of the card just like ranks. Something was bugging me, though, and I started to think that maybe the four suits as a whole were more of a property of the deck, and the individual suit was a property of the card. That's why I ended up separating them as part of the deck. However, I didn't like that either and I started thinking about the option where they might be used by both the deck and the card at the same time, and in that line of thinking it might be best to have them as a separate object that unites the cards with the deck, and so I came up with the second solution where the suit is a separate structure.
https://github.com/AleksandarDzh/card-game-basics/blob/24e3b571535f60f00630a39b82fa859aa6ce9fd1/CardGame_Basics/src/Deck.php#L13
It seems that a card's rank and its suite is being defined in two different places:
Card
classDeck
classCan you explain what is the idea behind this implementation?