Class GroupOfThree

java.lang.Object
  |
  +--GroupOfThree

public class GroupOfThree
extends Object

GroupOfThree represents a group of three Card objects. The order of the cards is not significant.

Version:
January 2004
Author:
Dave + Francis

Constructor Summary
GroupOfThree()
          Constructor for objects of class GroupOfThree
 
Method Summary
 void addCard(Card c)
          Adds a card to the group.
 boolean colorSet()
          Returns true if and only if there are three cards in the group, and the group forms a valid set.
 Card getCard(int whichCard)
          Returns a specified card from the group.
 boolean hasCard(Card c)
          Returns true if and only if the Card is in the group.
 boolean isSet()
          Determines if the group is a set.
 boolean numberSet()
          Determines if the group has valid numbers (e.g., 1,2,3 or 1,1,1, etc.).
 void removeCard(Card c)
          Removes the card from the group.
 boolean shadingSet()
          Determines if the group has valid shadings.
 boolean shapeSet()
          Determines if the group has valid shapes.
 String toString()
          Returns a string representation of the group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GroupOfThree

public GroupOfThree()
Constructor for objects of class GroupOfThree

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

colorSet

public boolean colorSet()
Returns true if and only if there are three cards in the group, and the group forms a valid set.

Returns:
Whether the group is a valid set.

getCard

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

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

hasCard

public boolean hasCard(Card c)
Returns true if and only if the Card is in the group.

Parameters:
c - The card to look for.
Returns:
Whether the card is in the group.

isSet

public boolean isSet()
Determines if the group is a set.

Returns:
True, if and only if the group is a valid set.

numberSet

public boolean numberSet()
Determines if the group has valid numbers (e.g., 1,2,3 or 1,1,1, etc.).

Returns:
True, if and only if the group is has valid numbers.

removeCard

public void removeCard(Card c)
Removes the card from the group. If the group does not contains this card does nothing.

Parameters:
c - The card to be removed.

shadingSet

public boolean shadingSet()
Determines if the group has valid shadings.

Returns:
True, if and only if the group is has valid shadings.

shapeSet

public boolean shapeSet()
Determines if the group has valid shapes.

Returns:
True, if and only if the group is has valid shapes.

toString

public String toString()
Returns a string representation of the group.

Overrides:
toString in class Object