Class Tableau

java.lang.Object
  |
  +--java.util.Observable
        |
        +--Tableau

public class Tableau
extends Observable

Tableau represents a group of Card objects. The size of the group is typically 12, but may be 15 (if there is no set in the 12) or a smaller multiple of 3 (if there are no cards remaining in the deck. The order of the cards in the tableau is not significant. Cards are added or removed only in a quantity of 3. Tableau extends Observable. Observers are notified with a Boolean false argument if the change is merely a highlighted value, and a true argument if cards have been added or removed.

Version:
January 2004
Author:
Tim Corica, Rudy Clausen, Matt Cook

Constructor Summary
Tableau()
          Constructor for objects of class Tableau
 
Method Summary
 void addCard(Card c)
          Adds a card to the group.
 void clear()
          Removes all cards from the tableau.
 void clearHighlight()
          Sets all cards in the tableau to not-highlighted status.
 boolean containsSet()
          Returns true if and only if there are three cards in the tableau that form a valid set.
 GroupOfThree findSet()
          Returns a GroupOfThree containing cards from the tableau that form a set.
 Card getCard(int whichCard)
          Returns a specified card from the tableau.
 GroupOfThree getHighlightedGroup()
          Gets the cards highlighted on the screen and returns them.
 boolean isLit(Card c)
          Returns true if and only if c is in the tableau and is highlighted.
 int numberLitCards()
          Returns the number of cards in the tableau that are currently highlighted.
 int numberOfCards()
          Returns the number of cards currently in the tableau.
 void refill(Deck d)
          Adds three cards to the tableau.
 void removeGroup(GroupOfThree g)
          Removes the cards in the group from the tableau if present.
 void toggleCard(Card c)
          Attempts to toggle the highlighted status of card c.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tableau

public Tableau()
Constructor for objects of class Tableau

Method Detail

addCard

public void addCard(Card c)
Adds a card to the group. If the group already contains three cards does nothing.

Parameters:
c - The card to be added

clear

public void clear()
Removes all cards from the tableau.


clearHighlight

public void clearHighlight()
Sets all cards in the tableau to not-highlighted status.


containsSet

public boolean containsSet()
Returns true if and only if there are three cards in the tableau that form a valid set.

Returns:
Whether the tableau contains a valid set.

findSet

public GroupOfThree findSet()
Returns a GroupOfThree containing cards from the tableau that form a set. If there is no set in the tableau, returns null.

Returns:
A valid set, or null.

getCard

public Card getCard(int whichCard)
Returns a specified card from the tableau.

Parameters:
whichCard - Either 0, 1, 2, ... or 12 or ...15.
Returns:
The specified card, or null if there is no card or whichCard is out of range.

getHighlightedGroup

public GroupOfThree getHighlightedGroup()
Gets the cards highlighted on the screen and returns them.


isLit

public boolean isLit(Card c)
Returns true if and only if c is in the tableau and is highlighted.


numberLitCards

public int numberLitCards()
Returns the number of cards in the tableau that are currently highlighted.


numberOfCards

public int numberOfCards()
Returns the number of cards currently in the tableau.

Returns:
The number of cards in the tableau, always 15 (includes null cards).

refill

public void refill(Deck d)
Adds three cards to the tableau.


removeGroup

public void removeGroup(GroupOfThree g)
Removes the cards in the group from the tableau if present. If the cards are not present, throws an exception (???).

Parameters:
g - The group of cards to be removed.

toggleCard

public void toggleCard(Card c)
Attempts to toggle the highlighted status of card c. If c is not lit, but there are already three cards highlighted, does nothing. If c is not present in the tableau, does nothing.