Home > Back-end >  Have bosses, help me to look at my this dou landlord, why not automatic sorting CARDS???????
Have bosses, help me to look at my this dou landlord, why not automatic sorting CARDS???????

Time:02-26

Package sdjgad;

import java.util.ArrayList;
Import the Java. Util. Collections;
Import the Java. Util. HashMap;
import java.util.List;
Import the Java. Util. The Map;

Public class DDZ {
Public static void main (String [] args) {
//create the collection
Map Pokers=new HashMap<> (a);
List List=new ArrayList ();
String [] huase={" plum blossom ", "spade", "red peach", "party piece"};
String [] shuzi={" 3 ", "4", "5", "6", "7", "eight" and "9", "10", "J", "Q", "K", "A", "2",};
Int num=0;
For (String STR: huase) {
For (String ste: shuzi) {
String poke=STR + ste;
Pokers. Put (num, poke);
List. The add (num);
num++;
}

}
Pokers. Put (num, "king");
List. The add (num++);
Pokers. Put (num, "wang");
List. The add (num);
System. The out. Println (" all parties: "+ pokers);
System. The out. Println (" index: "+ list);
//licensing
The Collections. Shuffle (list);
List Princess-themed=new ArrayList<> (a);
List Xiaohei=new ArrayList<> (a);
List Xiaowang=new ArrayList<> (a);
List Dipai=new ArrayList<> (a);
System. The out. Println (" washed card: "+ list);
For (int I=0; I & lt; List. The size (); I++) {

The Integer pokeNUM=list. Get (I);
If (i>=list. The size () - 3) {
Dipai. Add (pokeNUM);
} else if (I % 3==0) {
Princess-themed. Add (pokeNUM);
} else if (I % 3==1) {
Xiaohei. Add (pokeNUM);
} else if (I % 3==2) {
Xiaowang. Add (pokeNUM);
}
}
System. The out. Println (" floret: "+ kanpoker (princess-themed, pokers));
System. The out. Println (" the little black: "+ xiaohei);
System. Out. Println (" wang: "+ xiaowang);
System. The out. Println (" card: "+ dipai);
}

Private static String kanpoker (List & lt; Integer> Nums Map Pokers) {

The Collections. Sort (nums);//in order to sort out the sign

The StringBuilder sb=new StringBuilder ();
For (Integer num nums) {
String poker=pokers. Get (num);
Sb. Append (poker);
}
String STR=sb. ToString ();
Return the STR. The trim ();


}


}






CodePudding user response:

Check your watch carefully card method

CodePudding user response:

System. The out. Println (" floret: "+ kanpoker (princess-themed, pokers));
System. The out. Println (", "the little black + kanpoker (xiaohei, pokers));
System. The out. Println (" wang: "+ kanpoker (xiaowang, pokers));
System. The out. Println (" card: "+ kanpoker (dipai, pokers));
After correct or not correct
  • Related