I can't get the value of the hand once dealt.
Norm Radder wrote:
I can't get the value of the hand once dealt.
Can you post the print out that shows what you are talking about? Add some comments that describe what is wrong and show what you want it to be.
Junilu Lacar wrote:Also, an Ace can take on two values in BlackJack: 1 or 11. How are you going to represent that logic in your program?
Fred Kleinschmidt wrote:Here are a couple of thoughts about your Card class.
Why do you have variables rank and value? They are not independent. A single variable (rank) should be sufficient.
I would not have included a setValue() method. The rank (and therefore value) is fixed at construction time, and should be invariant after that.
You should priobably have a getRank() method.
The getValue() method should return rank.getCardValue(), since the value parameter is extraneous.
And you don't really need a getValue() method, since you could use something like
int value = card.getRank().getValue();
Paul D Pearson wrote:For v1 I'm designating an Ace to only represent 11. I will eventually have AceClass extend Card.
Junilu Lacar wrote:The General Responsibility Assignment Software Principles/Patterns (GRASP) will come into play here, in particular, Information Expert. Which class would have all the context/information needed to determine when an Ace should be valued as 1 or 11? That's where you should assign the responsibility. In your proposed design where a AceCard extends Card, an AceCard object still would not (and should not) have the context it needs to determine whether it should have a 1 or 11 value. If you had a "Hand" class, however, specifically a "BlackJackHand", then it would have all the information it needs to determine what the value of an Ace should be, given that it knows what the other cards are in the hand.