oop2.setGame
Class Card

java.lang.Object
  extended byoop2.setGame.Card

public class Card
extends Object

A Card from the game Set. Each card can have a count, a shading, a color, and a shape.


Field Summary
 int color
          The color of this card (0-2)
static int DIAMOND
          The shape Diamond
static int GREEN
          The color Green
 int number
          the number of symbols on this card (1-3)
static int OPEN
          The shading Open
static int OVAL
          The shape Oval
static int PURPLE
          The color Purple
static int RED
          The color Red
 int shading
          The shading of this card (0-2)
 int shape
          the shape on this card (0-2)
static int SOLID
          The shading Solid
static int SQUIGGLE
          The shape Squiggle
static int STRIPED
          The shading Striped
 
Constructor Summary
Card(int number, int color, int shading, int shape)
          Creates a new card with the specified attributes.
Card(String name)
          Constructed a card based on a String representation The String representation is the same 4 character string returned by the toString method, in the order Number, Shading, Color, Shape.
 
Method Summary
 boolean equals(Object o)
           
 String getImage()
          Returns the name of the gif file containing the graphical representation of this playing card.
 int hashCode()
           
 String toString()
          Returns a string representing the attributes of the card.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

number

public final int number
the number of symbols on this card (1-3)


shading

public final int shading
The shading of this card (0-2)


color

public final int color
The color of this card (0-2)


shape

public final int shape
the shape on this card (0-2)


RED

public static final int RED
The color Red

See Also:
Constant Field Values

PURPLE

public static final int PURPLE
The color Purple

See Also:
Constant Field Values

GREEN

public static final int GREEN
The color Green

See Also:
Constant Field Values

SOLID

public static final int SOLID
The shading Solid

See Also:
Constant Field Values

STRIPED

public static final int STRIPED
The shading Striped

See Also:
Constant Field Values

OPEN

public static final int OPEN
The shading Open

See Also:
Constant Field Values

SQUIGGLE

public static final int SQUIGGLE
The shape Squiggle

See Also:
Constant Field Values

DIAMOND

public static final int DIAMOND
The shape Diamond

See Also:
Constant Field Values

OVAL

public static final int OVAL
The shape Oval

See Also:
Constant Field Values
Constructor Detail

Card

public Card(int number,
            int color,
            int shading,
            int shape)
Creates a new card with the specified attributes.

Parameters:
number - The number for the card, which must be in the range [1,3].
color - The color of the card. Possible colors are Card.RED (0), Card.PURPLE (1), Card.GREEN (2).
shading - The shading of the card. Possible shadings are Card.SOLID (0), Card.STRIPED (1), Card.OPEN (2).
shape - The shape for the card. Possible shapes are Card.SQUIGGLE( 0), Card.DIAMOND (1), Card.OVAL (2).

Card

public Card(String name)
Constructed a card based on a String representation The String representation is the same 4 character string returned by the toString method, in the order Number, Shading, Color, Shape.

Parameters:
name - - String representation of the card
Method Detail

hashCode

public int hashCode()

equals

public boolean equals(Object o)

getImage

public String getImage()
Returns the name of the gif file containing the graphical representation of this playing card.

The file is expected to be in the "images/" folder. The name can be calculated as:
int c = (number + 3*color + 9*shape + 27 * shading)
c+".gif" if c>=10
"0"+c+".gif" if c< 10

Returns:
The name of the gif file for this card.

toString

public String toString()
Returns a string representing the attributes of the card. The attributes appear in the order Number,Shading,Color,Shape.
  1. Number may be {1,2,3}
  2. Color may be {R,P,G} for {Red,Purple,Green}.
  3. Shading may be {S,=,O} for {Solid,Striped,Open}.
  4. Shape may be {S,D,O} for {Squiggle,Diamond,Oval}.
So a possible string may be "1G=D" for a card with 1 green striped diamond.