闘地主発札アルゴリズム

9628 ワード

   

package poker;

import java.util.Random;

/**
 * Created by      on 2016/8/11.
 */

public class dealCards {

    static String[] flowerColor = {"  ", "  ", "  ", "  "};
    static String[] number = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
    static String[] cards = new String[54];

    public static void main(String[] args) {
        new dealCards_fuck(flowerColor, number, cards);
        new Upset(cards);
        new DistributeCards(cards);


    }

}

//  ,     
class dealCards_fuck {
    dealCards_fuck(String[] flowerColor, String[] number, String[] cards) {
        cards[52] = "  ";
        cards[53] = "  ";


        for (int i = 0; i < 52; i++) {
            cards[i] = flowerColor[i % 4] + number[i / 4];
        }

    }
}


//  
class Upset {
    Upset(String[] fuck) {

        for (int t = 0; t < 50; t++) {
            Random rand = new Random();
            for (int i = 0; i < fuck.length; i++) {
                int bitch = 0;

                for (; ; ) {
                    bitch = i + rand.nextInt(54 - i);
                    break;
                }

                String temp = fuck[bitch];
                fuck[bitch] = fuck[i];
                fuck[i] = temp;
            }
        }

    }


}

//  
class DistributeCards {
    String[] p1 = new String[17];
    String[] p2 = new String[17];
    String[] p3 = new String[17];

    DistributeCards(String[] fuck) {
        for (int i = 0; i < 17; i++) {
            p1[i] = fuck[i];
        }
        for (int i = 17, t = 0; i < 34; i++, t++) {
            p2[t] = fuck[i];
        }
        for (int i = 34, t = 0; i < 51; i++, t++) {
            p3[t] = fuck[i];
        }
        System.out.println("  1:");
        new show(p1);
        System.out.println();

        System.out.println("  2:");
        new show(p2);
        System.out.println();

        System.out.println("  3:");
        new show(p3);
        System.out.println();

        System.out.println("    ");
        for (int i = 51; i < 54; i++) {
            System.out.println(fuck[i]);
        }

    }
}


//   
class show {
    show(String[] fuck) {
        for (int i = 0; i < fuck.length; i++) {
            System.out.println(fuck[i]);
        }
    }
}