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

import java.util.Arrays;
import java.util.List;

public class CardSequence implements CardSource
{
	private final List<Card> aCards;

	public CardSequence(Card... pCards)
	{
		aCards = Arrays.asList(pCards);
	}

	@Override
	public boolean isEmpty()
	{
		return aCards.isEmpty();
	}

	public Card get(int pPosition)
	{
		return aCards.get(pPosition);
	}

	@Override
	public Card draw()
	{
		return aCards.remove(size() - 1);
	}

	public int size()
	{
		return aCards.size();
	}

	@Override
	public void accept(CardSourceVisitor pVisitor)
	{
		pVisitor.visitCardSequence(this);
	}
}