package com.syz.card;
import java.io
.Serializable;
public class Card implements Serializable{
private static final long serialVersionUID = -4279016186402068401L;
private int suit;
private int rank;
public static final int SPADE = 0;
public static final int HEART = 1;
public static final int CLUB = 2;
public static final int DIAMOND = 3;
public static final int BLACK = 4;
public static final int RED = 5;
private static final String[] suits = new String[] { "黑桃", "红桃", "梅花", "方块",
"小", "大" };
public static final int ACE = 1000;
public static final int TWO = 1001;
public static final int THREE = 1002;
public static final int FOUR = 1003;
public static final int FIVE = 1004;
public static final int SIX = 1005;
public static final int SEVEN = 1006;
public static final int EIGHT = 1007;
public static final int NINE = 1008;
public static final int TEN = 1009;
public static final int JACK = 1010;
public static final int QUEEN = 1011;
public static final int KING = 1012;
public static final int JOKER = 1013;
private static final String[] ranks = new String[] { "A", "2", "3", "4",
"5", "6", "7", "8", "9", "10", "J", "Q", "K", "王" };
public Card(int suit, int rank) {
if (suit > -1 && suit < 6) {
if (suit < 4) {
if (rank < 1000 || rank > 1012) {
throw new IllegalArgumentException("花色或点数参数错误!");
}
}
else {
if (rank != 1013) {
throw new IllegalArgumentException("花色或点数参数错误!");
}
}
}
else {
throw new IllegalArgumentException("花色参数错误!");
}
this.suit = suit;
this.rank = rank;
}
public int getSuit() {
return suit;
}
public int getRank() {
return rank;
}
@Override
public String toString() {
return suits[suit] + ranks[rank - 1000];
}
}