Introduction to OOP: Chapter 11: Replacement and Refinement [next] [previous] [audio] [real] [text]

Replacement in C++ - methods

int CardPile::canTake(Card * aCard)
{	// just say no
	return 0;
}

int SuitPile::canTake(Card * aCard)
{
	if (top == nilLink) {	// empty - can take ace
		if (aCard->rank() == 1) return 1;
		return 0;
		}
	if ((top->card())->suit() != aCard->suit())
		return 0;
	if (((top->card())->rank() + 1) == aCard->rank())
		return 1;
	return 0;
}
Intro OOP, Chapter 11, Slide 9