//
//
//  Generated by StarUML(tm) Java Add-In
//
//  @ Project : Poker Five Card Draw
//  @ File Name : Card.java
//  @ Date : 1/26/2015
//  @ Author : Pepper
//
//
/**
 * The Card class represents a single card. 
 * 
 **/
public class Card2 {
    private int rank;
    private String suit;
    /**
     * builds a new card
     *
     * @param    rank  card ranking with valid values: 2-10 J K Q A
     * @param    suit  Suit valid values: Hearts, Spades, Clubs, Diamonds
     **/
    public Card2(int rank, String suit) {
        if   (rank < 1 || rank > 13)  
        {  throw new IllegalArgumentException ("The rank was incorrect. Send 2-10 or A, J, Q, K");}
        if ( !(suit.equals("HEARTS") && suit.equals("SPADES") 
                && suit.equals("CLUBS") && suit.equals( "DIAMONDS" )))
        {  throw new IllegalArgumentException ("The suit was incorrect. Send HEART, SPADE, DIAMOND or CLUB");} 
        this.rank = rank;
        this.suit = suit;
    }

    /**
     * 
     * @return    a string such as Ace of Hearts or 2 of hearts
     **/
    public String toString() {
        return getRankName() + " of " + this.suit;

    }

    /**
     * Figures out the numeric value of a card
     * 
     * @return    a number representing the card score: A = 1; J = 11; Q = 12; K = 13; otherwise the number
     **/
    public int getcardScore() {
        return this.rank;
    }
    /**
     * Returns the full name of face cards  
     *
     * @return   the full name of face cards A = Ace; J = Jack; Q = Queen; K = King 2 - 10
     **/
    public String getRankName() {

        if (this.rank == 1) { return "Ace";}
        else if (this.rank == 11) { return "Jack";}
        else if (this.rank == 12) { return "Queen";}
        else if (this.rank == 13) { return "King";}
        else { return "" +   (char)( 49 + this.rank);}
    }
}
