
public class Card2 {

	//constants for face values
	private static int ACE = 0;
	private static int JACK = 10;
	private static int QUEEN = 11;
	private static int KING = 12;
	
	private static String ACE_ST = "Ace"; 
	private static String JACK_ST = "Jack";
	private static String QUEEN_ST = "Queen";
	private static String KING_ST = "King";

	// constants for suit values
	private static int CLUBS = 0;
	private static int DIAMONDS = 1;
	private static int SPADES = 2;
	private static int HEARTS = 3;
	
	private static String CLUBS_ST = "Clubs";
	private static String DIAMONDS_ST = "Diamonds";
	private static String SPADES_ST = "Spades";
	private static String HEARTS_ST = "Hearts";
	
	private String face; 
	private String suit;
	
	// creates a random card
	public Card2 () {
		int faceCode = (int) (Math.random () * 13);
		face = getFaceName(faceCode);
		int suitCode = (int) (Math.random () * 4);
		suit = getSuitName(suitCode);
	}
	
	public boolean isJack() {
		return face.equals(JACK_ST);
	}
	
	public boolean equals(Card2 other) {
		return face.equals (other.face) && suit.equals ( other.suit);
	}
	
	public boolean sameFace(Card2 other) {
		return face.equals(other.face);
	}
	
	// returns the score value of this card
	// presently this assigns a score of 1 to each card, but can be changed
	// to reflect other scoring schemes
	public int getScore() {
		return 1;
	}
	
	public String toString() {
		return getFaceName() + "  of  " + getSuitName();
	}
	
	private String getFaceName(int faceCode) {
		if (faceCode == ACE)
			return ACE_ST;
		else if (faceCode == JACK)
			return JACK_ST;
		else if (faceCode == QUEEN)
			return QUEEN_ST;
		else if (faceCode == KING)
			return KING_ST;
		else
			return "" + (faceCode + 1);
	}

	private String getFaceName() {
		return face;
	}

	private String getSuitName(int suitCode) {
		if (suitCode == CLUBS)
			return CLUBS_ST;
		else if (suitCode == DIAMONDS)
			return DIAMONDS_ST;
		else if (suitCode == HEARTS)
			return HEARTS_ST;
		else
			return SPADES_ST;
	}
	
	private String getSuitName() {
		return suit;
	}
	
}

