/**
* Copyright (C) 2022 by Martin Robillard. See https://codesample.info/about.html
*/
package e2.chapter6;
/**
* Represents an entity from which it is possible to obtain cards.
* This version can be polymorphically copied.
*/
public interface CardSource
{
/**
* Returns a card from the source.
*
* @return The next available card.
* @pre !isEmpty()
*/
Card draw();
/**
* @return True if there is no card in the source.
*/
boolean isEmpty();
/**
* @return A card source that is a deep copy (distinct object graph)
* of this card source.
*/
CardSource copy();
}
Chapter 6, insight #8
Use polymorphic copying to make copies of objects whose concrete type is not known at compile time. If the type is known at compile time, favor the simpler technique of copy constructors
Chapter 6, insight #8
Use polymorphic copying to make copies of objects whose concrete type is not known at compile time. If the type is known at compile time, favor the simpler technique of copy constructors