I'm trying to calculate score of simple BlackJack game. I want to be able for computer to choose when to count Ace card as 1 or 11 depending on the situation of cards but I don't want to hard code this situation.
How should I do this?
This is how I count score in my dealers/players hand class:
public int calcScore()
{
int score = 0;
Link current = first;
while(current != null)
{
score = score + current.card.getValue();
current = current.next;
}
return score;
}
This is how I specify value of a card in Card class:
public int getValue()
{
int value = 0;
if (rank == 1)
value = 11;
else if (rank == 11 || rank == 12 || rank == 13)
value = 10;
else
value = rank;
return value;
}