with information from lecture filled in (in red)
| Deck |
|
-cards:Card[] -cardsInDeck:int +DECK_SIZE:int |
|
+Deck() +deal():Card +deal(int):Card[] +shuffle():void +reset():void +toString():String |
/**
* Deals one card from the deck, decreasing the number of cards in the
* deck by one.
*
* @return the next Card object in the deck; null if deck is empty
*/
public Card deal() {
if (cardsInDeck == 0)
return null;
cardsInDeck--;
Card dealtCard = cards[cardsInDeck];
cards[cardsInDeck] = null;
return dealtCard;
}
/**
* Shuffles the deck (i.e. randomly reorders the cards in the deck).
*/
public void shuffle() {
}
/**
* Resets the deck so that it has all its cards. Note that the order of
* the cards may be random.
*/
public void reset() {
}