Class RowOfPiles

java.lang.Object
  extended by RowOfPiles

public class RowOfPiles
extends java.lang.Object

Class that represents a row of card piles (or, more technically, a row of the top cards).

Version:
11/20/06
Author:
Dave Reed

Constructor Summary
RowOfPiles()
          Constructs an empty row of piles.
 
Method Summary
 void addPile(Card top)
          Adds a new pile at the end of the current row of piles.
 boolean movePile(Card fromTop, Card toTop)
          Moves a pile on top of another pile either 1 or 3 spots away.
 int numPiles()
          Determines the number of piles in the row.
 java.lang.String toString()
          Returns a string representation of the row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RowOfPiles

public RowOfPiles()
Constructs an empty row of piles.

Method Detail

addPile

public void addPile(Card top)
Adds a new pile at the end of the current row of piles.

Parameters:
top - the card on top of the new pile

movePile

public boolean movePile(Card fromTop,
                        Card toTop)
Moves a pile on top of another pile either 1 or 3 spots away.

Parameters:
fromTop - the card on top of the pile to be moved
toTop - the card on top of the pile to be covered
Returns:
true if the move was completed (i.e., the piles with specified tops exist, are 1 or 3 spots apart, and the cards match either rank or suit).

numPiles

public int numPiles()
Determines the number of piles in the row.

Returns:
the number of piles

toString

public java.lang.String toString()
Returns a string representation of the row.

Overrides:
toString in class java.lang.Object
Returns:
a string containing all of the top cards from the piles