Because we changed this structure definition, we will have to only slightly modify the Hand operations. Fortunately, none of the function prototypes will need to change:
- In carddeck_3.c, modify the InitializeHand() function, as follows:
void InitializeHand( Hand* pHand ) {
pHand->cardsDealt = 0;
for( int i = 0; i < kCardsInHand ; i++ ){
pHand->hand[i] = NULL;
}
}
We can now use a loop to set each of our Card pointers in the hand[] array to NULL.
- Next, we can simplify the AddCardToHand() function because we no longer need the GetCardInHand() method, as follows:
void AddCardToHand( Hand* pHand , Card* pCard ) {
if( pHand->cardsDealt == kCardsInHand ) return;
pHand->hand[ pHand->cardsDealt ] = pCard;
pHand->cardsDealt++;
}
As before, we first check whether our hand is full. Then, we simply set the pointer value to the given Card structure to the appropriate...