// Arup Guha
// 11/12/2009
// Card class written for AP Computer Science Class
// Manages a regular playing card.

import java.util.*;

public class Card {
	
	final private static String[] SUITS = {"Clubs","Diamonds","Hearts","Spades"};
	final private static String[] KINDS = {"King", "Ace", "Two", "Three", "Four", "Five",
										   "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen"};
	
	private int kind;
	private String suit;
	
	// Pre-condition: s must be either "Clubs", "Diamonds", "Hearts", or "Spades"
	//                k must be in between 0 and 12, inclusive. 0=King, 1=Ace, 11=Jack, 12=Queen
	//                and the rest of the numbers 2-10 are as expected.
	public Card(String s, int k) {
		suit = s;
		kind = k;
	}
	
	// Returns a randomly generated Card.
	public Card(Random r) {
		int intsuit = Math.abs(r.nextInt())%4;
		suit = SUITS[intsuit];
		kind = Math.abs(r.nextInt())%13;
	}
	
	// Returns a String representation of this card.
	public String toString() {
		return KINDS[kind]+" of "+suit;
	}
	
	// Returns the value of this card in the game of BlackJack.
	// Assumes Aces are ALWAYS worth 1 point.
	public int blackJackValue() {
		
		// All of these cards are assigned 10 points.
		if (kind == 0 || kind > 9)
			return 10;
			
		// These cards are lined up in the array to be worth their index value.
		else
			return kind;
	}
}