Browse Source

branch test

Jennifer Chao 6 years ago
parent
commit
91ba386663
1 changed files with 27 additions and 14 deletions
  1. 27
    14
      src/main/java/io/zipcoder/casino/CardGame/BlackJack/BlackJack.java

+ 27
- 14
src/main/java/io/zipcoder/casino/CardGame/BlackJack/BlackJack.java View File

@@ -7,6 +7,7 @@ import io.zipcoder.casino.Interfaces.Gamble;
7 7
 import io.zipcoder.casino.Player;
8 8
 
9 9
 import java.util.ArrayList;
10
+import java.util.Scanner;
10 11
 
11 12
 public class BlackJack extends CardGame implements Gamble {
12 13
 
@@ -30,18 +31,12 @@ public class BlackJack extends CardGame implements Gamble {
30 31
         this.numOfTurns = 0;
31 32
     }
32 33
 
33
-//    public BlackJack(){
34
-//        this.blackJackPlayers = new ArrayList<BlackJackPlayer>();
35
-//    }
36
-
37
-//    public BlackJack(Player player) {
38
-//        BlackJackPlayer blackJackPlayer = new BlackJackPlayer(player);
39
-//        this.blackJackPlayers.add(blackJackPlayer);
40
-//    }
41
-
42 34
     // basically draw
43
-    public Card hit() {
44
-        return null;
35
+    public void hit(BlackJackPlayer blackJackPlayer) {
36
+        setJustDealt(false);
37
+        Card playerCard1 = deck.draw();
38
+        blackJackPlayer.addToHand(playerCard1);
39
+        System.out.println(blackJackPlayer.getPlayerHand().toString());
45 40
     }
46 41
 
47 42
     public void flip() {
@@ -50,6 +45,7 @@ public class BlackJack extends CardGame implements Gamble {
50 45
     }
51 46
 
52 47
     public void split() {
48
+        setJustDealt(false);
53 49
         // must be the same card value
54 50
     }
55 51
 
@@ -57,6 +53,8 @@ public class BlackJack extends CardGame implements Gamble {
57 53
         if (getJustDealt() == true) {
58 54
             blackJackPlayer.addToBetPot(blackJackPlayer.getInitialBet());
59 55
         }
56
+
57
+        setJustDealt(false);
60 58
         // must be right after deal, and you can only get one more card
61 59
     }
62 60
 
@@ -76,19 +74,22 @@ public class BlackJack extends CardGame implements Gamble {
76 74
 
77 75
     public void deal(BlackJackPlayer blackJackPlayer) {
78 76
         // BlackJackPlayer player1 = blackJackPlayers.get(playerIndex);
79
-        blackJackPlayers.add(blackJackPlayer);
77
+        // blackJackPlayers.add(blackJackPlayer);
80 78
         // should we move this to start instead? we would also need to deal for each player if multiple
79
+        deck.shuffle();
81 80
         Card playerCard1 = deck.draw();
82 81
         blackJackPlayer.addToHand(playerCard1);
83 82
 
84 83
         Card dealerCard1 = deck.draw();
85 84
         dealerHand.add(dealerCard1);
85
+        System.out.println("Mystery Card");
86 86
 
87 87
         Card playerCard2 = deck.draw();
88 88
         blackJackPlayer.addToHand(playerCard2);
89 89
 
90 90
         Card dealerCard2 = deck.draw();
91 91
         dealerHand.add(dealerCard2);
92
+        System.out.println(dealerCard2);
92 93
 
93 94
         setJustDealt(true);
94 95
     }
@@ -98,8 +99,21 @@ public class BlackJack extends CardGame implements Gamble {
98 99
     }
99 100
 
100 101
     public void start() {
102
+        Scanner reader = new Scanner(System.in);
103
+        System.out.println("Enter an initial bet: ");
104
+        int initialBet = reader.nextInt();
105
+
106
+        start(initialBet);
107
+    }
108
+
109
+    public void start(int initialBet) {
101 110
         // upon starting a new game, every player places a bet? make a loop???
102
-        betAmount(50, blackJackPlayers.get(0));
111
+        BlackJackPlayer blackJackPlayer = blackJackPlayers.get(0);
112
+        if (initialBet < minBet) {
113
+            System.out.println("TOo low");
114
+        } else {
115
+            blackJackPlayer.setInitialBet(betAmount(initialBet, blackJackPlayers.get(0)));
116
+        }
103 117
     }
104 118
 
105 119
     public void end() {
@@ -126,7 +140,6 @@ public class BlackJack extends CardGame implements Gamble {
126 140
                 break;
127 141
             }
128 142
         }
129
-
130 143
     }
131 144
 
132 145
     public int betAmount(int amount, BlackJackPlayer blackJackPlayer) {