Originally Posted by
Norm
Have you tried debugging the code by adding some println statements to print out the values of variables as the code executes so you can see where the code is going wrong?
Yes, It's only printing the values of the last card
--- Update ---
I just put inside the for loop, the count works now
public int getPlayerCards(int times)
{
System.out.print("Your cards: ");
for(int a=1; a<=times; a++)
{
shuffleCards = rand.nextInt(cards.length-1) + 0;
System.out.print(cards[shuffleCards] + ", ");
showCard = showCard.concat(cards[shuffleCards].concat(", "));
if(shuffleCards >=4 && shuffleCards <= 7)
{
playerPoints = 2;
}
if(shuffleCards >=8 && shuffleCards <= 11)
{
playerPoints = 3;
}
if(shuffleCards >=12 && shuffleCards <= 15)
{
playerPoints = 4;
}
if(shuffleCards >=16 && shuffleCards <= 19)
{
playerPoints = 5;
}
if(shuffleCards >=20 && shuffleCards <= 23)
{
playerPoints = 6;
}
if(shuffleCards >=24 && shuffleCards <= 27)
{
playerPoints = 7;
}
if(shuffleCards >=28 && shuffleCards <= 31)
{
playerPoints = 8;
}
if(shuffleCards >=32 && shuffleCards <= 35)
{
playerPoints = 9;
}
if(shuffleCards >=36 && shuffleCards <= 51)
{
playerPoints = 10;
}
if((shuffleCards == 40)|| (shuffleCards == 42) || (shuffleCards == 49))
{
playerPoints = 13;
}
if(shuffleCards == 11)
{
playerPoints = 0;
}
if((shuffleCards >= 0 && shuffleCards<= 3) && (playerTotal <= 22))
{
playerPoints = 11;
}
if((shuffleCards >= 0 && shuffleCards<= 3) && (playerTotal > 22))
{
playerPoints = 1;
}
playerTotal = playerPoints + playerTotal;
}
return shuffleCards;
}
public int showPlayerCardValue()
{
System.out.print("(Total " + playerTotal + ")");
return playerTotal;
}