/**
* Copyright (C) 2022 by Martin Robillard. See https://codesample.info/about.html
*/
package e2.chapter8;
/**
* Represents an entity from which it is possible to obtain cards.
* This version is visitable.
*/
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();
/**
* Accepts a visitor for traversal into this structure.
*
* @param pVisitor The visitor to accept
*/
void accept(CardSourceVisitor pVisitor);
}
Making this version of CardSource
visitable allows to
support an open-ended set of operations on the CardSource
(and the object hierarchy it can represent). This is achieved
by adding a single accept
method that takes an abstract visitor
as its parameter.
Making this version of CardSource
visitable allows to
support an open-ended set of operations on the CardSource
(and the object hierarchy it can represent). This is achieved
by adding a single accept
method that takes an abstract visitor
as its parameter.