import java.util.ArrayList;
import java.util.Collections;
import java.util.TreeSet;
class Poker
{
String name;
int age;
public Poker(String name,int age)
{
this.name=name;
this.age=age;
}
}
public class Test
{
public static void main(String[] args)
{
ArrayList<Poker> al=new ArrayList<>();
String[] arr={"♥","♠","♣","♦"};
String[] arr1={"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
for(String color : arr)
{
int count=1;
for(String num : arr1)
{
Poker p=new Poker((color+num),count++);
al.add(p);
}
}
al.add(new Poker("大王",15));
al.add(new Poker("小王",14));
Collections.shuffle(al);
ArrayList<Poker> al1=new ArrayList<>();
ArrayList<Poker> al2=new ArrayList<>();
ArrayList<Poker> al3=new ArrayList<>();
ArrayList<Poker> al4=new ArrayList<>();
for(int i=0;i<al.size();i++)
{
if(i>=al.size()-3)
{
al4.add(al.get(i));
}
else
{
if(i%3==0)
al1.add(al.get(i));
if(i%3==1)
al2.add(al.get(i));
if(i%3==2)
al3.add(al.get(i));
}
}
for(Poker s : al1)
{
System.out.print(s.name+",");
System.out.println(s.age+",");
}
}
} |
|