If you are only drawing cards, not peeking ahead or inserting any, then an easy option is to implement the deck as a list of cards and yield a random one on draw. E.g.:
1 2 3 4 5 6 7 8
| class Deck { private List<Card> theDeck; public Card draw() { if (theDeck.size()==0) throw NoSuchElementException(); else return theDeck.remove(Math.random() * theDeck.size()); } } |
From the client's point of view (that is, according to the object's interface), the deck is shuffled, and in an OO system, that's all that matters
