public void sendCard()
{
Scanner show=new Scanner(System.in);
//player是玩家类,其中纸牌属性设置为set型
Palyer []player=new Palyer[2];
for(int i=0;i<2;i++)
{
System.out.println("请输入玩家id: ");
String id=show.next();
System.out.println("请输入用户姓名: ");
String name=show.next();
player[i]=new Palyer(id,name);
}
int i=0;
Cards是玩家类,cardSet是我定义的一个set型容器,用来存储打乱后的牌
for(Cards card2:cardSet)
{
if(i==0||i==2)
{
player[0].cards.add(card2);
i++;
continue;
}
else if(i==1||i==3)
{
player[1].cards.add(card2);
i++;
continue;
}
else
break;
}
for(int j=0;j<2;j++)
{
System.out.print("玩家"+j+"的牌为: ");
for(Cards card3:player[j].cards)
{
System.out.print(card3.type+card3.ID+" ");
}
System.out.println();
}
}