📌  相关文章
📜  时间:2018-08-10 标签:c#remove duplicate cards - 不管是什么代码示例

📅  最后修改于: 2022-03-11 14:57:19.145000             🧑  作者: Mango

代码示例1
public void displayCards(List disp) {

    int cardNumber = 0;
    Set myCards = new HashMap();
    for (ImageView c : disp) {

        cardNumber++;

        Card newCard;

        do {
            rank = rand(13) + 2;
            int i = rand(4);
            if (i == 0) {
                suit = 's';
            } else if (i == 1) {
                suit = 'h';
            } else if (i == 2) {
                suit = 'd';
            } else {
                suit = 'c';
            }
            newCard = new Card(rank, suit);
        } while(myCards.contains(newCard));

        myCards.add(newCard);


        if (cardNumber == 1) {
            dc1 = newCard;
        } else if (cardNumber == 2) {
            dc2 = newCard;
        } else if (cardNumber == 3) {
            dc3 = newCard;
        } else if (cardNumber == 4) {
            pc1 = newCard;
        } else if (cardNumber == 5) {
            pc2 = newCard;
        } else {
            pc3 = newCard;
        }
    }