title: OOP Design for Card Game Classes
body: <p>What would be the best approach when designing the following classes applying design patterns?</p>
  
  <ul>
  <li><strong>Deck</strong> - <em>addCard, deal, shuffle, getTopCard, removeTopCard, removeAllCards</em></li>
  <li><strong>Hand</strong> - <em>addCard, removeCard, getCard,removeAllCards</em> </li>
  <li><strong>DiscardPile</strong> - <em>addCard, getTopCard, removeTopCard, removeAllCards</em>  </li>
  <li><strong>MeldPile</strong> - <em>addCard, removeAllCards</em></li>
  </ul>
  
  <p>(The MeldPile holds all the melds in the table.)</p>
  
  <p>For me, I think the <code>getTopCard</code> and <code>removeTopCard</code> are just a wrapper of <code>getCard</code> and <code>removeCard</code>, as it just get the top position of a card then pass it to <code>getCard</code> or <code>removeCard</code>.</p>
  
  <p>Should I use composition? strategy pattern? or just create a another class called <strong>CardPile</strong> and use it as the base class of the above class? Really appreciate if you could provide a sample code on this.</p>