| Introduction to OOP | Chapter 9: A Solitare Game: | next | previous | audio | real | text |
public class SuitPile : CardPile {
public SuitPile (int x, int y) : base(x, y) { }
public override bool canTake (PlayingCard aCard ) {
if( isEmpty )
{ return( aCard.rank == 0 ); }
PlayingCard topCard = top;
return( ( aCard.suit == topCard.suit ) &&
( aCard.rank == topCard.rank + 1 ) );
}
}
Note use of keyword base in constructor, keyword override
in canTake, call on properties.