Bug 334

Summary: Dealer doesn't keep hitting if the total points are less than 17
Product: Blackjack Game Reporter: MAK Kai Chung <kaicmak6-c>
Component: GameAssignee: MAK Kai Chung <kaicmak6-c>
Status: CONFIRMED ---    
Severity: major    
Priority: High    
Version: unspecified   
Hardware: PC   
OS: Windows   

Description MAK Kai Chung 2019-12-04 05:15:31 HKT
I followed the instruction in the readme.md to setup the game. First, I created a Stub Deck for testing purpose. The deck contains cards with small values only where  there were no cards with more than 10 values. 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:
    7 of Spades
    9 of Spades
Your total is 16

Dealer is showing the 2 of Spades

Hit (H) or Stand (S)? 
User stands.
Dealer's cards are
	2 of Spades
	3 of Spades
Dealer hits and gets the 8 of Spades
Dealer's total is 13

You won, 16 points to 13.

From the above actual result, we see that the dealer get "hit" once only at the end and stop even when the total score was 13 only. 

According to rules of blackjack, the dealer should keep drawing cards if his / her score does not exceed 17. Thus, the dealer should not get "hit" only once when the total score is 13 only. The dealer should keep getting "hit" until it reached 17 or gone bust (more than 21).

I suspect that in the Game component, there wasn't a iterator handling this case. The original code was fine but they should be wrapped by a while loop. The loop there keeps drawing cards if the dealer's score is more than 17, or end the game if it is more than 21.