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

/**
 * Simple visitor that prints all cards in the source, in
 * no specified order.
 */
public class PrintVisitor implements CardSourceVisitor
{
	public static void main(String[] args)
	{
		PrintVisitor visitor = new PrintVisitor();
		Deck deck = new Deck();
		deck.accept(visitor);
	}
	
	@Override
	public void visitCompositeCardSource(CompositeCardSource pCompositeCardSource)
	{
		for( CardSource source : pCompositeCardSource )
		{
			source.accept(this);
		}
	}

	@Override
	public void visitDeck(Deck pDeck)
	{
		for( Card card : pDeck)
		{
			System.out.println(card);
		}
	}

	@Override
	public void visitCardSequence(CardSequence pCardSequence)
	{
		for( int i = 0; i < pCardSequence.size(); i++ )
		{
			System.out.println(pCardSequence.get(i));
		}
	}
}