librejack

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

commit 9fce55d46873e83430bb61f970d8fd13ec133a3f
parent 5fcb268793497766018ab9f561426b547101c1b1
Author: Michael Neuper <73108749+michaelneuper@users.noreply.github.com>
Date:   Sat,  8 Oct 2022 14:56:40 +0200

update Controller.java

Diffstat:
Msrc/controller/Controller.java | 29+++++++++--------------------
1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/src/controller/Controller.java b/src/controller/Controller.java @@ -49,7 +49,7 @@ public class Controller { public void startRound() { // if we run out of cards -// if(wins > 0 || losses > 0 || pushes > 0) { + if(wins > 0 || losses > 0 || pushes > 0) { // TODO: change code :) System.out.println("\nStarting next round...\nWins: " + wins + "\nLosses: " + losses + "\nPushes: " + pushes + "\nBalance: " + balance); dealer.getHand().discardHandToDeck(discarded); player.getHand().discardHandToDeck(discarded); @@ -58,27 +58,16 @@ public class Controller { if(deck.cardsLeft() < 4) { deck.reloadDeckFromDiscard(discarded); } -// } - - // ask the player to bet - // Scanner inBet = new Scanner(System.in); - // try { - // // System.out.println("Enter a bet amount: "); - // // bet = Double.parseDouble(inBet.next()); // TODO: add parseDouble - // // inBet.close(); - - // // in case someone bets an amount bigger than their balance - // if(bet > balance) { - // System.out.println("You don't have that much money, try again:"); - // Scanner newBet = new Scanner(System.in); - // bet = newBet.nextDouble(); - // newBet.close(); - // } - // } catch (NumberFormatException e) { - // System.out.println(e); - // } + } + + // ask the player what their bet is bet = Double.parseDouble(JOptionPane.showInputDialog("Enter a bet amount")); + if(bet > balance) { // in case the player tries to bet more than they have + System.out.println("You don't have that much money! Please try again"); + bet = Double.parseDouble(JOptionPane.showInputDialog("Enter a bet amount")); + } + // give the dealer 2 cards dealer.getHand().takeCardFromDeck(deck); dealer.getHand().takeCardFromDeck(deck);