0

here i have part of a blackjack program im trying to write, and when i try compiling the terminal displays the "cannot find symbol" error for symbol"cardAr" in the constructor and the nextCard method. i can't find where the problem is, as i have defined (i think) the variable at the beginning and stackoverflow doesn't seem to have any similar questions. can someone help?

String[] cardList = {"A","2","3","4","5","6","7","8","9","10","Jack","Queen","King"};

private int deckNums;
private ArrayList<Card> cardAr = new ArrayList<Card>();
private int cardsLeft = cardAr.size();

public River(int d) {
    this.deckNums = d;
    for (int i=0; i<cardList.length; i++) {
        Card tempCard = new Card(cardList[i]);
        cardAr.add(tempCard);
    }
}

public ArrayList getAr() {
    return cardAr;
}

public Card nextCard() {
    // random card 
    if (cardAr.size() >0) {
        int cardPlace = ThreadLocalRandom.current().nextInt(0, cardsLeft+ 1);
        Card ret  = cardAr(cardPlace);
        cardAr.add(cardAr(cardPlace));
        return ret;
    }
}

0 Answers0