/**
 * Copyright (C) 2022 by Martin Robillard. See https://codesample.info/about.html
 */
package e2.chapter7;

import java.util.Iterator;

/**
 * A specialized Deck that stored a reference to 
 * all the cards drawn since the last shuffle.
 */
public class MemorizingDeck extends Deck {
	
	private CardStack aDrawnCards = new CardStack();
	
	/**
	 * @return The cards drawn.
	 */
	public Iterator<Card> getDrawnCards() {
		return aDrawnCards.iterator();
	}
	
	@Override
	public void shuffle() {
	
		super.shuffle();
if( aDrawnCards != null ) { aDrawnCards.clear(); }
} @Override public Card draw() {
Card card = super.draw(); aDrawnCards.push(card); return card;
} @Override
public MemorizingDeck clone() { MemorizingDeck clone = (MemorizingDeck) super.clone(); clone.aDrawnCards = new CardStack(aDrawnCards); return clone; }
}