how to create a deck of cards constructor

后端 未结 3 1390
孤独总比滥情好
孤独总比滥情好 2021-01-21 17:37

so far this is what I have

import java.util.Random;
public class DeckOfCards
{
public static final int DECK_SIZE = 52;

//Instance Variables
private boolean[] de         


        
3条回答
  •  误落风尘
    2021-01-21 17:55

    Considering the assignment, you should be storing true rather than false in the deck array. Moreover, I would make it a 2-D array of Booleans - a dimension for the suite, and a dimension for the rank.

    private boolean deck[][] = new boolean[13][4];
    
    public DeckOfCards() {
        for (int rank = 0 ; rank != 13 ; rank++)
            for (int suite = 0 ; suite != 4 ; suite++)
                deck[rank][suite] = true;
    }
    
    boolean containsCard(int rank, int suite) {
        return deck[rank][suite];
    }
    

提交回复
热议问题