-3

私はテキサス ホールデム ゲームを書いており、ユーザー ハンドをランク​​付けするためにこのメソッドを作成しました。それを一般的なメソッドに変えて、ディーラー ハンドを渡し、2 つを比較してどちらのハンドが優れているかを確認できるようにしたいと考えています。これを汎用メソッドに変換するのを手伝っていただければ幸いです。

public int rankCards(ArrayList<Integer> rankHandList){
    //creates a list to put the card ranks into 
    ArrayList <Integer> newList;
    newList = new ArrayList<>();
    //Checks the rankHandList i created above
    for(int x = 0; x<=rankHandList.size()-1; x++){
        int rank = rankHandList.get(x);
        //takes all the cards and gets them between 0 and 12
        while(rank >= 13){
            rank = rank -13;
        }
        //if a card = 12 it is an ace
        if(rank == 12)
            newList.add(rank);
        //if a card = 11 it is a king
        if(rank == 11)
            newList.add(rank);
        //if a card = 10 it is a queen
        if(rank == 10)
            newList.add(rank);
        //if a card = 9 it is a jack
        if(rank == 9)
            newList.add(rank);
        //if a card = 8 it is a 10
        if(rank == 8)
            newList.add(rank);
        //if a card = 7 it is a 9
        if(rank ==7)
            newList.add(rank);
        //if a card = 6 it is a 8
        if(rank ==6)
            newList.add(rank);
        //if a card = 5 it is a 7
        if(rank ==5)
            newList.add(rank);
        //if a card = 4 it is a 6
        if(rank ==4)
            newList.add(rank);
        //if a card = 3 it is a 5
        if(rank ==3)
            newList.add(rank);
        //if a card = 2 it is a 4
        if(rank == 2)
            newList.add(rank);
        //if a card =1 it is a 3
        if(rank ==1)
            newList.add(rank);
        //if a card = 0 it is a 2
        if(rank ==0)
            newList.add(rank);
    }

  //SENDS THE CARDS I JUST RANKED FROM 0-12 TO MAKE THE BEST HAND   
    makeBestHand(newList);
    return 0;
}
4

1 に答える 1

1

私はあなたが何を望んでいたかを完全には理解していませんでした.

public int rankCards(ArrayList<Integer> rankHandList) {
    // Creates a list to put the card ranks into 
    ArrayList <Integer> newList = new ArrayList<Integer>();

    // Checks the rankHandList i created above
    for (int rank : rankHandList) {
        // Add card rank into the list, after module 13 to normalize rank.
        newList.add(rank%13);
    }

    //SENDS THE CARDS I JUST RANKED FROM 0-12 TO MAKE THE BEST HAND   
    makeBestHand(newList);
    return 0;
}
于 2013-11-05T22:47:56.497 に答える