首页 > IT职业 > IT职场 > java第三季:简单扑克牌游戏
玩家类Player
public class Player {
public String id;
public String name;
List getCard;
public Player(String id,String name){
this.id=id;
this.name=name;
getCard=new ArrayList();
}
} 牌类型Card
/**
* 该类用作对牌类型的处理,
* @author Dandelion
*
*/
public class Card {
public String[] cardColor={"黑桃","红桃","梅花","方片"};
public String[] cardNum={"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
} 单张牌获取GetCard
/**
*
* 单张牌
*
* @author Dandelion
*
*/
public class GetCard {
public String color;
public String num;
/**
* 牌的花色和点数
* @param color
* @param num
*/
public GetCard(String color,String num){
this.color=color;
this.num=num;
}
} 测试工具类TestCard
public class TestCard {
List getCards;
List players=new ArrayList();;
public void testCreateCard(){
Card card=new Card();
getCards=new ArrayList();
for(int i=0;itmp2)
{k[p][0]=tmp1;k[p][1]=colortmp1;}
else if(tmp1colortmp2)
{
k[p][0]=tmp2;
k[p][1]=colortmp2;
}
else
{k[p][0]=tmp1;k[p][1]=colortmp1;}
}
}
if(k[0][0]>k[1][0])
System.out.println("玩家"+players.get(0).name+"的牌大,获胜!!!!");
else if(k[0][0]k[1][1])
System.out.println("玩家"+players.get(1).name+"的牌大,获胜!!!!");
else
System.out.println("玩家"+players.get(0).name+"的牌大,获胜!!!!");
}
}
public static void main(String[] args) {
TestCard tc=new TestCard();
tc.testCreateCard();
tc.testCreatePlayer();
tc.testStartGame();
tc.compareRule();
}
}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4827/viewspace-2799140/ ,如需转载,请注明出处,否则将追究法律责任。