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

/**
 * A CardSource decorator that logs cards drawn from the
 * source.
 */
public class LoggingDecorator implements CardSource {
	
	private CardSource aSource;
	
	public LoggingDecorator( CardSource pSource ) {
		aSource = pSource;
	}

	@Override
	public Card draw() {
		Card card = aSource.draw();
		System.out.println(card);
		return card;
	}

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

	@Override
	public CardSource copy() {
		return new LoggingDecorator(aSource.copy());
	}
}