smithers.cards
Class BuildingDownByAlternatingColours

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

public class BuildingDownByAlternatingColours
extends AbstractBuildingRule

A building rule which allows a card to be placed if it is the opposite colour to, and one rank lower than, the top card.


Field Summary
 
Fields inherited from class smithers.cards.AbstractBuildingRule
canAddMultiple
 
Constructor Summary
BuildingDownByAlternatingColours()
          Constructs a new instance of this rule.
BuildingDownByAlternatingColours(boolean startsWithKing)
          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

BuildingDownByAlternatingColours

public BuildingDownByAlternatingColours()
Constructs a new instance of this rule. This uses the default, allowing any card to be placed into an empty space.


BuildingDownByAlternatingColours

public BuildingDownByAlternatingColours(boolean startsWithKing)
Constructs a new instance of this rule.

Parameters:
startsWithKing - true iff only kings may be placed in empty spaces
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