Bug 334 - Dealer doesn't keep hitting if the total points are less than 17
Summary: Dealer doesn't keep hitting if the total points are less than 17
Status: CONFIRMED
Alias: None
Product: Blackjack Game
Classification: Unclassified
Component: Game (show other bugs)
Version: unspecified
Hardware: PC Windows
: High major
Assignee: MAK Kai Chung
URL:
Depends on:
Blocks:
 
Reported: 2019-12-04 05:15 HKT by MAK Kai Chung
Modified: 2019-12-04 05:15 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.