smithers.cards
Class BuildingUpBySuits

java.lang.Object
  extended by smithers.cards.AbstractBuildingRule
      extended by smithers.cards.BuildingUpBySuits
All Implemented Interfaces:
BuildingRule

public class BuildingUpBySuits
extends AbstractBuildingRule

A building rule which allows a card to be placed if it is the same suit as, and one rank higher than, the top card. Only aces may be placed in an empty space.


Field Summary
 
Fields inherited from class smithers.cards.AbstractBuildingRule
canAddMultiple
 
Constructor Summary
BuildingUpBySuits()
          Constructs a new instance of this rule.
 
Method Summary
 boolean goesInSpace(Card c)
          Determines whether the specified card can be placed in an empty space.
 boolean goesOn(Card c1, Card c2)
          Determines whether card c2 can be placed on top of card c1.
 
Methods inherited from class smithers.cards.AbstractBuildingRule
canAddCard, canAddCards
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BuildingUpBySuits

public BuildingUpBySuits()
Constructs a new instance of this rule.

Method Detail

goesOn

public boolean goesOn(Card c1,
                      Card c2)
Determines whether card c2 can be placed on top of card c1.

Specified by:
goesOn in class AbstractBuildingRule
Parameters:
c1 - the card to move onto
c2 - the card to be moved
Returns:
true iff the card can be moved

goesInSpace

public boolean goesInSpace(Card c)
Determines whether the specified card can be placed in an empty space.

Specified by:
goesInSpace in class AbstractBuildingRule
Parameters:
c - the card to be moved
Returns:
true iff the card can be moved into a space