Class Board

java.lang.Object
  extended by Board

public class Board
extends java.lang.Object

Represents a 4 X 13 board of cards. The cards can be either face up or face down. Cards can also be removed from the board. Bugs: none known


Constructor Summary
Board()
          Constructs a Board object.
 
Method Summary
 GameCard getCard(int row, int col)
          Returns the card at the given row and column.
 boolean invalidBoardPosition(int row, int col)
          Returns true if and only if (row, col) is not a valid position on the board.
 boolean isEmpty()
          Returns true if there are no more cards on the board.
 boolean removeCard(GameCard card)
          Removes the given card from the board.
 boolean removeCard(int row, int col)
          Removes the card at the given row and column.
 java.lang.String toString()
          Returns a string representation of the board suitable for printing with System.out.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Board

public Board()
Constructs a Board object. The board is initialized to be a 4 x 13 grid of face down game cards.

Method Detail

getCard

public GameCard getCard(int row,
                        int col)
Returns the card at the given row and column. If the position is invalid, null is returned.

Parameters:
row - the row index (starting at 0)
col - the column index (starting at 0)
Returns:
the card at (row, col); null if (row, col) is not valid

removeCard

public boolean removeCard(int row,
                          int col)
Removes the card at the given row and column. If the position is invalid or there is no card in that position, false is returned; otherwise, true is returned.

Parameters:
row - the row index (starting at 0)
col - the column index (starting at 0)
Returns:
true if a card was sucessfully removed; false otherwise

removeCard

public boolean removeCard(GameCard card)
Removes the given card from the board. If the card is not found, false is returned; otherwise, true is returned.

Parameters:
card - the card to remove from the board
Returns:
true if a card was sucessfully removed; false otherwise

isEmpty

public boolean isEmpty()
Returns true if there are no more cards on the board.

Returns:
true if no more cards on board; false otherwise

invalidBoardPosition

public boolean invalidBoardPosition(int row,
                                    int col)
Returns true if and only if (row, col) is not a valid position on the board.

Parameters:
row - the row index (starting at 0)
col - the column index (starting at 0)
Returns:
is (row, col) an invalid position?

toString

public java.lang.String toString()
Returns a string representation of the board suitable for printing with System.out.

Overrides:
toString in class java.lang.Object
Returns:
string representation of the board