地主は、シャッフルライセンス、カードを読み取る実現します

パッケージcn.javacode.map.demo。

輸入はjava.util.ArrayList;
輸入java.util.Collections。
輸入java.util.HashMapを;
輸入はjava.util.List; 

パブリック クラスFightAgainstLandlord {
     公共 静的 ボイドメイン(文字列[]引数){
         // 准备牌 
        のHashMap <整数、文字列>ポーカー= 新規 HashMapの<> (); 
        ArrayListの <整数> pokerIndex = 新しい ArrayListを<> (); 
        リストの<string>色= List.of( "♠"、 "♥"、 "♣"、 "♦" )。
        リスト<ストリング>番号= List.of( "2"、 "A"、 "K"、 "Q"、 "J"、 "10"、 "9"、 "8"、 "7"、 "6"、「 5" 、 "4"、 "3" )。
        int型のインデックス= 0 ; 
        pokerIndex.add(インデックス)。
        poker.put(インデックス、 "大王" ); 
        インデックス ++ ; 
        pokerIndex.add(インデックス)。
        poker.put(インデックス、 "小王" ); 
        インデックス ++ ;
        {(数字列N)
             のための(列C:色){ 
                pokerIndex.add(インデックス)
                poker.put(インデックス、C + N)。
                インデックス ++ ; 
            }
        }
        System.out.print(ポーカー)。
        System.out.println(); 

        // 洗牌
        Collections.shuffle(pokerIndex)。
        System.out.println(pokerIndex)。

        // 发牌 
        のArrayList <Integer型> player01 = 新しい ArrayListを<> (); 
        ArrayListの <整数> player02 = 新しい ArrayListを<> (); 
        ArrayListの <整数> player03 = 新しい ArrayListを<> (); 
        ArrayListの <整数> diPai = 新しい ArrayListを<> ();
        以下のためにint型 i = 0; iはpokerIndex.sizeを()<。(I> = 51 ){ 
                diPai.add(pokerIndex.get(I))。
            } そう であれば(私%3 == 0 ){ 
                player01.add(pokerIndex.get(I))。
            } そう であれば(私%3 == 1 ){ 
                player02.add(pokerIndex.get(I))。
            } そう であれば(私%3 == 2 ){ 
                player03.add(pokerIndex.get(I))。
            } 
        } 
        Collections.sort(player01)。
        Collections.sort(player02)。
        Collections.sort(player03)。
        Collections.sort(diPai)。

        / * 
        のSystem.out.println(diPai)。
        System.out.println(player01)。
        System.out.println(player02)。
        System.out.println(player03)。

         * / 

        // 看牌 
        lookPoker( "player01" ポーカー、player01)。
        lookPoker( "player02" ポーカー、player02)。
        lookPoker( "player03" ポーカー、player03)。
        lookPoker( "diPai" ポーカー、diPai)。

    } 
    パブリック 静的 ボイド lookPoker(文字列名、ハッシュマップ<整数、文字列>ポーカー、のArrayList <整数> リスト){ 
        System.out.printlnは(名 + ":" )。
        以下のための(整数k:リスト){ 
            文字列V = poker.get(K)。
            System.out.print(V +」 " ); 
        } 
        のSystem.out.println(); 
    } 

}

 

おすすめ

転載: www.cnblogs.com/reyinever/p/11116857.html