importjava.util.ArrayList;importjava.util.Random;importjava.util.Scanner;publicclassStudent2{Stringcolor;Stringletter;publicstaticclasscard{privateintcolornumber;privatei...
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
public class Student2{
String color;
String letter;
public static class card{
private int colornumber;
private int stringnumber;
Student2 stu=new Student2();
public String toString(){
Student2 stu=new Student2();
switch(colornumber){
case 0:stu.color="黑桃";break;
case 13:stu.color="红桃";break;
case 26:stu.color="梅花";break;
case 39:stu.color="方块";break;
}
switch(stringnumber){
case 11:stu.letter="J";break;
case 12:stu.letter="Q";break;
case 13:stu.letter="K";break;
case 14:stu.letter="A";break;
default:stu.letter=String.valueOf(stringnumber);
}
return stu.color+stu.letter;
}
}
public void washcard(){
Random rd=new Random();
card card1=new card();
List first=new ArrayList();
List second=new ArrayList();
List result=new ArrayList();
for(int number=0;number<52;number++){
card1.colornumber=number/13*13;
card1.stringnumber=number%13+2;
first.add(card1);
}
for(int i=0;i<=52;i++){
first.add(rd.nextInt(),first.remove(rd.nextInt()));
}
try{
for(int i=0;i<=1;i++){
result.add(first.get(rd.nextInt()));
second.add(first.get(rd.nextInt()));
}
}
catch(Exception e){
System.out.println("出现的异常为"+e);
}
Collections.sort(result);
Collections.sort(second);
}
展开