纸牌比大小java代码 扑克牌比大小java编程

JAVA中随机生成各有13张扑克牌(每张牌从“A”到“K”)的两组,比较两组数对应位置上牌点数大小的程序?package card;
import java.util.Hashtable;
public class Card {
/**
* 0:方块3纸牌比大小java代码:黑桃 4纸牌比大小java代码:王
*/
public static final int DIAMODE=0;
/**1:梅花*/
public static final int CLUB=1;
/**2:红桃*/
public static final int HEART=2;
/**3:黑桃*/
public static final int SPADE=3;
/**4:王*/
static final int WANG=4;
/**0:方块3:黑桃 4:王*/
private static String[] SUIT_NAMES=new String[]{"方块","梅花","红桃","黑桃","王"};
public static final int THREE=0;
public static final int FOUR=1;
public static final int FIVE=2;
public static final int SIX=3;
public static final int SEVEN=4;
public static final int EIGHT=5;
public static final int NINE=6;
public static final int TEN=7;
public static final int JACK=8;
public static final int QUEEN=9;
public static final int KING=10;
public static final int ACE=11;
public static final int DUCK=12;
public static final int BALCK=13;
public static final int COLOR=14;
public static String[] RANK_NAMES=new String[]{"3","4","5","6","7"
,"8","9","10","J","Q","K","A","2","小","大"};
private int suit,rank;
// private static class Entry{
//private String name;
//private int value;
//public Entry(String name,int value) {
//this.name=name;
//this.value=https://www.04ip.com/post/value;
//}
//public int getValue() {
//return value;
//}
//public void setValue(int value) {
//this.value = https://www.04ip.com/post/value;
//}
//@SuppressWarnings("unused")
//public String getName() {
//return name;
//}
//@SuppressWarnings("unused")
//public void setName(String name) {
//this.name = name;
//}
// }
//public static Entry[] table = new Entry[120];
static HashtableString, Integer table = new HashtableString,Integer();
static{
for (int i = 0; iSUIT_NAMES.length; i++) {
//Entry entry = new Entry(SUIT_NAMES[i],i);
//table[SUIT_NAMES[i].hashCode()%120]=entry;
table.put(SUIT_NAMES[i], i);
}
for (int i = 0; iRANK_NAMES.length; i++) {
//Entry entry = new Entry(RANK_NAMES[i],i);
//table[RANK_NAMES[i].hashCode()%120]=entry;
table.put(RANK_NAMES[i], i);
}
}
public int getSuit() {
return suit;
}
public void setSuit(int suit) {
this.suit = suit;
}
public int getRank() {
return rank;
}
public void setRank(int rank) {
this.rank = rank;
}
public Card(int suit,int rank) {
setSuit(suit);
setRank(rank);
}
public Card(String strName){
String suitName;
String rankName;
if(strName.endsWith("王")){
suitName=strName.substring(1);
rankName=strName.substring(0,1);
}else{
suitName=strName.substring(0,2);
rankName=strName.substring(2);
}
setSuit(findSuit(suitName));
setRank(findRank(rankName));
}
private int findSuit(String suitName) {
//return table[suitName.hashCode()%120].getValue();
return table.get(suitName);
}
private int findRank(String rankName) {
return table.get(rankName);
}
@Override
public String toString() {
if(suit==Card.WANG)
return RANK_NAMES[rank]+SUIT_NAMES[suit];
return SUIT_NAMES[suit]+RANK_NAMES[rank];
}
@Override
public boolean equals(Object obj) {
if(obj==null)
return false;
if(obj==this)
return true;
if(obj instanceof Card){
Card other=(Card)obj;

推荐阅读