Commit Graph

52 Commits

Author SHA1 Message Date
Dave Burke
937778657e Remove redundant Card record code
Java Records automatically acquire an implementation of equals and
hashCode that accounts for their components. They also have read
accessors for their components (card.suit() to get the suit).
2022-03-18 17:01:06 -05:00
Mitch Peck
5df021b3e4 Clean up comments and convert Card to a record 2022-03-18 12:52:14 -05:00
Mitch Peck
b1b703ea01 Fix dealer initialization 2022-03-16 21:27:37 -05:00
Mitch Peck
0b181dbd3f shouldPlayDealer & playDealer implementations, formatting to mimic original code 2022-03-11 21:12:59 -06:00
Mitch Peck
6107eed714 Handle dealer's total in evaluateRound 2022-03-09 20:43:56 -06:00
Mitch Peck
ff6302bf6a Implement evaluateRound with tests 2022-03-09 20:25:10 -06:00
Dave Burke
ea317a7b04 Handle 'an' vs 'a' grammar 2022-03-05 09:53:41 -06:00
Dave Burke
79d8c3bdff Fill out javadoc 2022-03-05 09:47:15 -06:00
Dave Burke
9dd1c465b6 Test insurance collection 2022-03-05 09:28:27 -06:00
Dave Burke
d1bf5d08f4 Handle insurance 2022-03-04 13:02:26 -06:00
Dave Burke
6f409e0865 Print total after STAY 2022-03-03 22:10:54 -06:00
Dave Burke
ff42b21b0a Mimic a real deal
Just because it's fun.
2022-03-03 22:10:54 -06:00
Dave Burke
b43a50901a Simplify bet validation 2022-03-03 22:10:54 -06:00
Dave Burke
d1bdd7889d Refactor scoreHand and compareHands into ScoringUtils 2022-03-03 21:55:30 -06:00
Dave Burke
387f4e3634 Make play() tests more readable 2022-03-03 21:49:47 -06:00
Dave Burke
e498983e59 Print total of each hand 2022-03-03 21:46:24 -06:00
Dave Burke
d52a001e26 Fix output for Double Down 2022-03-03 21:44:42 -06:00
Dave Burke
669496dfc7 Fix toString for Ace 2022-03-03 21:43:29 -06:00
Dave Burke
4e83ea6664 Add a couple TODOs 2022-03-02 22:20:41 -06:00
Dave Burke
e01e492171 Use List instead of LinkedList where possible 2022-03-02 22:16:03 -06:00
Dave Burke
c2d52438c5 Refactor Game.play() to handle split hands more elegantly 2022-03-02 22:15:44 -06:00
Dave Burke
99f8f427ac Add TODO to make Card a Record 2022-03-02 22:14:56 -06:00
Dave Burke
61568f1369 Initial playSplitHand implementation 2022-02-22 13:03:35 -06:00
Mitch Peck
d2e61454db Update player with split fields, stub out playSplit, and playSplit tests 2022-02-19 18:06:20 -06:00
Mitch Peck
40e22aa880 Implement compareHands method, add compareHands tests and fix UserIO Test 2022-02-18 19:35:54 -06:00
Dave Burke
a6a56b6f9d Use double to store bets
The original basic allowed fractional bets.
2022-02-11 13:02:22 -06:00
Dave Burke
f4e2e9e391 Fix print call syntax 2022-02-11 12:37:15 -06:00
Dave Burke
dfb12751ca Add TODO to use fractions for bets 2022-02-11 12:37:09 -06:00
Dave Burke
293de38a75 Add notes about insurance 2022-02-09 21:51:31 -06:00
Dave Burke
2e87fea99f Add comments and tasks 2022-02-09 21:40:27 -06:00
Dave Burke
b9ba37c8f2 Implement play() and scoreHand() 2022-02-09 21:19:04 -06:00
Dave Burke
670a2b02be Add example i/o test 2022-02-07 21:59:02 -06:00
Dave Burke
9ff276863f Refactor to allow testing side effects
By externalizing the source of i/o and randomness for shuffling, we can
inject non-interactive and deterministic behavior during unit tests.
2022-02-07 21:59:02 -06:00
Dave Burke
fad187cab2 Limit number of decks to 1
The subroutine to get a card shuffles 52 cards when the deck is run
through:

100 REM--SUBROUTINE TO GET A CARD.  RESULT IS PUT IN X.
110 IF C<51 THEN 230
120 PRINT "RESHUFFLING"
130 FOR D=D TO 1 STEP -1
140 C=C-1
150 C(C)=D(D)
160 NEXT D
170 FOR C1=52 TO C STEP -1
180 C2=INT(RND(1)*(C1-C+1))+C
190 C3=C(C2)
200 C(C2)=C(C1)
210 C(C1)=C3
220 NEXT C1
230 X=C(C)
240 C=C+1
250 RETURN
2022-02-03 08:31:04 -06:00
Dave Burke
be61d65117 Implement unit tests for Blackjack Java 2022-02-02 21:36:16 -06:00
Mitch Peck
9736325656 Implement print initial deal 2022-02-02 19:15:37 -06:00
Mitch Peck
b6900ea332 Update Player object and initialize Players 2022-02-01 20:21:30 -06:00
Dave Burke
dc58554575 Remove a junk TODO 2022-01-25 21:25:16 -06:00
Dave Burke
6e4f8722f9 Add a couple more notes 2022-01-25 21:19:15 -06:00
Dave Burke
3b0a44b108 Add Blackjack/java outline with TODO placeholders 2022-01-25 21:16:26 -06:00
Dave Burke
5dd157e9a8 Implement shuffled deck 2022-01-23 21:36:57 -06:00
Dave Burke
de5b3bbf4c Make Card immutable 2022-01-23 21:36:42 -06:00
Dave Burke
727aa0e83e Fix imports in Player 2022-01-23 21:17:22 -06:00
Dave Burke
9bf89593c5 Make Suit an enum in Card 2022-01-23 21:17:10 -06:00
Dave Burke
04472431f3 Fix inputs to match original BASIC behavior. 2022-01-23 21:07:19 -06:00
Mitch Peck
6991f66012 Add Player and Card objects 2022-01-22 20:15:09 -06:00
Dave Burke
7845e3df16 Prompt for bets and add notes on classes 2022-01-21 13:01:03 -06:00
Dave Burke
2cd9b8cfb3 Formatting fixes 2022-01-21 13:00:35 -06:00
Dave Burke
41424b6ee2 Refactor input prompts
After experimenting with both versions, I find System.console() to
produce more readable code than using a Scanner.
2022-01-20 21:56:51 -06:00
Dave Burke
93ef518768 Implement instructions prompt 2022-01-18 12:55:21 -06:00