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

/**
 * Visitor that prints a representation of the hierarchical structure
 * of a card source.
 */
public class StructurePrinterVisitor extends AbstractCardSourceVisitor
{
	private int aTab = 0;
	
	private String tab()
	{
		StringBuilder result = new StringBuilder();
		for( int i = 0; i < aTab; i++ )
		{
			result.append(" ");
		}
		return result.toString();
	}
	
	@Override
	public void visitCompositeCardSource(CompositeCardSource pCompositeCardSource)
	{
		System.out.println(tab() + "Composite");
		aTab++;
		super.visitCompositeCardSource(pCompositeCardSource);
		aTab--;
	}

	@Override
	public void visitDeck(Deck pDeck)
	{
		System.out.println(tab() + "Deck");
	}

	@Override
	public void visitCardSequence(CardSequence pCardSequence)
	{
		System.out.println(tab() + "CardSequence");
	}
}