Class ZetTable

java.lang.Object
  extended byZetTable

public class ZetTable
extends java.lang.Object

Represents a card table with a deck and an array of open cards for the game of Set.


Constructor Summary
ZetTable()
          Creates a new deck and opens dfltOpenCards cards.
 
Method Summary
 int cardsInDeck()
          Returns the number of cards left in the deck.
 void compactOpenCards()
          If there are gaps in the first dfltOpenCards and some open cards beyond dfltOpenCards, the latter are moved to fill the gaps.
 boolean enoughOpen()
          Indicates whether there is a sufficient number of open cards.
 int[] findZet()
          Finds a "set" in the open cards.
 ZetCard getOpenCard(int i)
          Returns the open card with a given index.
 boolean open3Cards()
          Opens three cards from the deck if three cards are available in the deck.
 void remove3Cards(int[] indices)
          Removes three cards with given indices from the open cards.
 java.lang.String toString()
          Returns a string representation of this "set table".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ZetTable

public ZetTable()
Creates a new deck and opens dfltOpenCards cards.

Method Detail

cardsInDeck

public int cardsInDeck()
Returns the number of cards left in the deck.

Returns:
the number of cards left in the deck.

getOpenCard

public ZetCard getOpenCard(int i)
Returns the open card with a given index. If the index is out of bounds or the card with this index is not open, returns null.

Returns:
the open card with a given index, or null if the index is out of bounds.

enoughOpen

public boolean enoughOpen()
Indicates whether there is a sufficient number of open cards.

Returns:
true if numOpenCards >= dfltOpenCards; false otherwise.

findZet

public int[] findZet()
Finds a "set" in the open cards.

Returns:
an array of the indices of the three "set" cards, or null if no sets are found.

open3Cards

public boolean open3Cards()
Opens three cards from the deck if three cards are available in the deck.

Returns:
true if the cards are opened; false otherwise.

remove3Cards

public void remove3Cards(int[] indices)
Removes three cards with given indices from the open cards.


compactOpenCards

public void compactOpenCards()
If there are gaps in the first dfltOpenCards and some open cards beyond dfltOpenCards, the latter are moved to fill the gaps.


toString

public java.lang.String toString()
Returns a string representation of this "set table".

Returns:
a string that lists all the open cards (including null cards) followed by an '\n' character, and finally the count of cards left in the deck.