Bug 333

Summary: The Hand component counts face cards as 11, 12, 13 points repectively
Product: Blackjack Game Reporter: MAK Kai Chung <kaicmak6-c>
Component: HandAssignee: MAK Kai Chung <kaicmak6-c>
Status: CONFIRMED ---    
Severity: major    
Priority: High    
Version: unspecified   
Hardware: PC   
OS: Windows   
Deadline: 2019-10-23   

Description MAK Kai Chung 2019-12-04 03:41:58 HKT
I followed the instruction in the readme.md to play the game. First, I created a Stub Deck for testing purpose. There are a Jack of King, a Queen of Hearts and a Jack of Diamonds. The test case is included in the TestBlackjack.java file. Then I ran the test case and observe the result.

This is the output:

Your cards are:
    King of Spades
    Queen of Hearts
Your total is 25

Dealer is showing the 2 of Spades

Hit (H) or Stand (S)? Please respond H or S:  Please respond H or S:  
User hits.
Your card is the Jack of Diamonds
Your total is now 36

You busted. You lose.
Dealer's other card was the 2 of Hearts

From the above actual result, we can see the sum of King and Queen are 25, 36 after drawing an additional Jack. However, this is wrong calculation. The final score should not be so high.

It is expected to have a score of 20 and 30 after drawing the cards because the game should treat the value of Face cards as 10.

In the getBlackjackValue() of Hand, it will return the sum of total card values of the hand object. Since the Card component uses a unique card value to identify different card name, Jack, Queen and King have 11, 12, 13 values respectively. However, I suspect that the getBlackjackValue() method didn't handle the case when the card value is higher than 10 and treat them as 10 points only. Thus, 11 + 12 + 23 = 36 results in the above output.

I fixed the issue by adding a condition to the getBlackjackValue() method to check if they are face cards and count them as 10 points only instead of their values directly.
Comment 1 MAK Kai Chung 2019-12-04 03:44:09 HKT
I fixed the issue by adding a condition to the getBlackjackValue() method to check if they are face cards and count them as 10 points only instead of their values directly.