/*******************************************************************************
Main Class:			Concentration

Author:				Rebecca Hasti, hasti@cs.wisc.edu
					copyright 2000, all rights reserved
Course:				CS 302, Summer 2000

Compiler:			Metrowerks CodeWarrior (JDK 1.2)
Platform:			Windows NT 4.0 (or Windows 95)
*******************************************************************************/

/**
 * Represents a playing card that can be either face up or face down.
 * The playing card has a face value, a suit, and a suit color (red or black),
 *
 * Bugs:	none known
 **/
public class GameCard extends Card {

	////////////////////////////////////////
	// Data Members
	////////////////////////////////////////
	private boolean faceUp;  // is the card face up?
	private boolean color;   // color of the suit; value is either GameCard.RED 
	                         // or GameCard.BLACK
	
	/** Represents the suit color red (for diamonds and hearts). */
	public static final boolean RED = true;
	
	/** Represents the suit color black (for clubs and spades). */
	public static final boolean BLACK = false;
	
	////////////////////////////////////////
	// Constructors
	////////////////////////////////////////
	
	/**
	 * Constructs a GameCard object with the given face value and suit value.
	 * The card is face up if the value of faceUp is true and face down
	 * otherwise.
	 * The face value of the card is set to 1 if an invalid face value is 
	 * given; the suit of the card is set to HEARTS if an invalid suit is 
	 * given.
	 *
	 * @param face the face value of the card
	 * @param suit the suit of the card
	 * @param faceUp a boolean indicating if the card is face up
	 **/	
	public GameCard(int face, int suit, boolean faceUp) {
		super(face, suit);
		this.faceUp = faceUp;
		color = (suit == Card.HEARTS || suit == Card.DIAMONDS);
		
	}
	
	/**
	 * Constructs a GameCard object with the same face value and suit value as
	 * the Card object given.
	 * The game card is face up if the value of faceUp is true and face down
	 * otherwise.
	 *
	 * @param card the card whose face value and suit value to copy
	 * @param faceUp a boolean indicating if the card is face up
	 **/		
	public GameCard(Card card, boolean faceUp) {
		this(card.getFace(), card.getSuit(), faceUp);
	}
	
	
	////////////////////////////////////////
	// Public Methods
	////////////////////////////////////////

	/**
	 * Returns the suit color of the card.
	 * @return suit color (either GameCard.RED or GameCard.BLACK)
	 **/
	public boolean getSuitColor() { return color; }
	
	/**
	 * Returns true if the card is face up and false otherwise.
	 * @return is the card face up?
	 **/	
	public boolean isFaceUp() { return faceUp; }
	
	/**
	 * Flips the card, either from face up to face down or vice versa.
	 **/
	public void flip() { faceUp = !faceUp; }
	
	/**
	 * Returns a String representing the game card.  If the card is face up,
	 * the string contains the face value and suit; if the card is face down,
	 * the string is "XXX".
	 * @return string representation of the game card
	 **/
	public String toString() {
		String s;
		if (faceUp) 
			s = super.toString();
		else
			s = "XXX";
		return s;	
	}
}