@Test public void testCanMoveTo_Empty() { assertTrue(aPile.canMoveTo(ACE_CLUBS)); assertFalse(aPile.canMoveTo(THREE_CLUBS)); }
public boolean canMoveTo(Card pCard) { assert pCard != null; if( isEmpty() ) { return pCard.getRank() == Rank.ACE; } else { return pCard.getSuit() == peek().getSuit() && pCard.getRank().ordinal() == peek().getRank().ordinal()+1; } }
FoundationPile { public boolean canMoveTo(Card pCard) { assert pCard != null; if( isEmpty() ) { return pCard.getRank() == Rank.ACE; } else { return pCard.getSuit() == peek().getSuit() && pCard.getRank().ordinal() == peek().getRank().ordinal()+1; } } }
FoundationPile { public boolean canMoveTo(Card pCard) { assert pCard != null; if( isEmpty() ) { return pCard.getRank() == Rank.ACE; } else { return pCard.getSuit() == peek().getSuit() && pCard.getRank().ordinal() == peek().getRank().ordinal()+1; } }  }
FoundationPile { public boolean canMoveTo(Card pCard) { assert pCard != null; if( isEmpty() ) { return pCard.getRank() == Rank.ACE; } else { return pCard.getSuit() == peek().getSuit() && pCard.getRank().ordinal() == peek().getRank().ordinal()+1; } }  boolean isEmpty(); Card peek(); Card pop(); void push(Card pCard); boolean canMoveTo(Card pCard); }
FoundationPile { public boolean canMoveTo(Card pCard) { assert pCard != null; if( isEmpty() ) { return pCard.getRank() == Rank.ACE; } else { return pCard.getSuit() == peek().getSuit() && pCard.getRank().ordinal() == peek().getRank().ordinal()+1; } }  boolean isEmpty(); Card peek(); Card pop(); void push(Card pCard); boolean canMoveTo(Card pCard);  }