Home How to add a specific value in a value in the array list
Reply: 0

How to add a specific value in a value in the array list

Yale.W
1#
Yale.W Published in 2017-12-07 21:27:32Z

So I am doing my school project- black jack, and I try to debug it.

for (int suit = 0; suit < 4; suit++) {                 
        String character = null;
        switch (suit) {
            case 0:
                character = "\u2660";
                break;
            case 1:
                character = "\u2665";
                break;
            case 2:
                character = "\u2666";
                break;
            case 3:
                character = "\u2663";
        }
        for (int num = 1; num <= 13; num++) {
            deck.add(character + Integer.toString(num));
        }
    }
    for (int i = 0; i < 2; i++) {                                                     // this for loop deals two card to the player.
        selectTheCardInIndex = deal.nextInt(deck.size() - deleteCard);
        cardFromList = deck.get(selectTheCardInIndex);
        if (cardFromList.length() > 2) {
            PlayerValue += 10;
        } else if (cardFromList.charAt(1) == 1) {
            NumberOfAcePlayerHave += 1;
        } else {
            NumberOfAcePlayerHave += cardFromList.charAt((1));
        }
        deck.remove(selectTheCardInIndex);
    }

however the PlayerValue doesn't show me the value I want, it works if the card dealer is ace, ten, jack, queen, or king. but 2-9 doesn't work.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30667 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO