I am trying to pick up C ++. Everything went well until my “practical” program hit me with a very shallow grip. I believe this problem is related to the design problem.
Think of Blackjack (21). I did some classes.
The deck consists of - for simplicity - has an array of cards.
-He can show all the cards
- You can shuffle
-He can remove cards.
Hand - deck - profitably
-He can calculate the value of his hand
-He can add cards in his hand
Now, to get to my problem - player design
-A player has a hand (private access)
My problem with the player is that the hand has a method function called addCardToHand. I feel a sense of redundancy / poor design if I need to create a player method called addCardToHand (card c) in which calls and transfers are in the same method.
or
declare Hand h as a public member and in 'main ()' do something like
Player p;
card card;
phaddCard (Acard);
Any advice would be enlightening and much appreciated. Keep in mind that I'm studying.
source share