librejack

Blackjack clone written in java
git clone https://github.com/michaelneuper/librejack.git
README | Files | Log | Refs | LICENSE

commit bfcd891b73da54b366ff73197853f2c1e5f81c7f
parent 23839d9c0fa66c9ced8b87e4bdb0fd51a3f56373
Author: Michael Neuper <73108749+michaelneuper@users.noreply.github.com>
Date:   Sat,  8 Oct 2022 09:16:12 +0200

update makeDecision method

Diffstat:
Msrc/model/Player.java | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/model/Player.java b/src/model/Player.java @@ -18,6 +18,11 @@ public class Player extends Person { super.setName("Player"); } + /** + * Allows the player to decide to hit or stand + * @param deck deck to draw from + * @param discard deck to discard to + */ public void makeDecision(Deck deck, Deck discard) { int decision = 0; @@ -34,6 +39,20 @@ public class Player extends Person { input.next(); } } + + // if they decide to hit + if (decision == 1) { + + this.hit(deck, discard); // hit the deck and discard + + if(this.getHand().calculateValue() > 20) { + return; // return if they have blackjack or busted + } else { + this.makeDecision(deck, discard); // allow them to hit or stand if they don't have 21 or blackjack + } + } else { + System.out.println("You stand."); // assume they stand if they hit a number other than 1 + } } // Deck playerDeck = new Deck(); // empty deck for the player