To save space, Javadoc comments have been removed from the code shown here in those parts of the GameCard class that were previously posted. See the GameCard.java file for the omitted Javadoc comments.
public class GameCard extends Card { private boolean faceUp; // is the card face up? private boolean color; // color of the suit; // value is either GameCard.RED // or GameCard.BLACK public static final boolean RED = true; public static final boolean BLACK = false;
Subclass constructor should:
public GameCard(int face, int suit, boolean faceUp) { super(face, suit); this.faceUp = faceUp; color = (suit == Card.HEARTS || suit == Card.DIAMONDS); } public GameCard(Card card, boolean faceUp) { this(card.getFace(), card.getSuit(), faceUp); }
public boolean getSuitColor() { return color; } public boolean isFaceUp() { return faceUp; } public void flip() { faceUp = !faceUp; } public boolean match(GameCard otherCard) { return (this.getFace() == otherCard.getFace() && this.getSuitColor() == otherCard.getSuitColor()); }
public String toString() { String s; if (faceUp) s = super.toString(); else s = "XXX"; return s; } public boolean equals(Object obj) {