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

/**
 * A visitor to compute the total number of cards in a card 
 * source.
 */
public class CountingVisitor extends AbstractCardSourceVisitor
{
	private int aCount = 0;
	
	@Override
	public void visitDeck(Deck pDeck)
	{
		for( @SuppressWarnings("unused") Card card : pDeck)
		{
			aCount++;
		}
	}

	@Override
	public void visitCardSequence(CardSequence pCardSequence)
	{
		aCount += pCardSequence.size();
	}
	
	public int getCount() 
	{ 
		return aCount; 
	}
	
	public void reset()
	{
		aCount = 0;
	}
}