Jennifer Chao 6 gadus atpakaļ
vecāks
revīzija
91ba386663

+ 27
- 14
src/main/java/io/zipcoder/casino/CardGame/BlackJack/BlackJack.java Parādīt failu

7
 import io.zipcoder.casino.Player;
7
 import io.zipcoder.casino.Player;
8
 
8
 
9
 import java.util.ArrayList;
9
 import java.util.ArrayList;
10
+import java.util.Scanner;
10
 
11
 
11
 public class BlackJack extends CardGame implements Gamble {
12
 public class BlackJack extends CardGame implements Gamble {
12
 
13
 
30
         this.numOfTurns = 0;
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
     // basically draw
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
     public void flip() {
42
     public void flip() {
50
     }
45
     }
51
 
46
 
52
     public void split() {
47
     public void split() {
48
+        setJustDealt(false);
53
         // must be the same card value
49
         // must be the same card value
54
     }
50
     }
55
 
51
 
57
         if (getJustDealt() == true) {
53
         if (getJustDealt() == true) {
58
             blackJackPlayer.addToBetPot(blackJackPlayer.getInitialBet());
54
             blackJackPlayer.addToBetPot(blackJackPlayer.getInitialBet());
59
         }
55
         }
56
+
57
+        setJustDealt(false);
60
         // must be right after deal, and you can only get one more card
58
         // must be right after deal, and you can only get one more card
61
     }
59
     }
62
 
60
 
76
 
74
 
77
     public void deal(BlackJackPlayer blackJackPlayer) {
75
     public void deal(BlackJackPlayer blackJackPlayer) {
78
         // BlackJackPlayer player1 = blackJackPlayers.get(playerIndex);
76
         // BlackJackPlayer player1 = blackJackPlayers.get(playerIndex);
79
-        blackJackPlayers.add(blackJackPlayer);
77
+        // blackJackPlayers.add(blackJackPlayer);
80
         // should we move this to start instead? we would also need to deal for each player if multiple
78
         // should we move this to start instead? we would also need to deal for each player if multiple
79
+        deck.shuffle();
81
         Card playerCard1 = deck.draw();
80
         Card playerCard1 = deck.draw();
82
         blackJackPlayer.addToHand(playerCard1);
81
         blackJackPlayer.addToHand(playerCard1);
83
 
82
 
84
         Card dealerCard1 = deck.draw();
83
         Card dealerCard1 = deck.draw();
85
         dealerHand.add(dealerCard1);
84
         dealerHand.add(dealerCard1);
85
+        System.out.println("Mystery Card");
86
 
86
 
87
         Card playerCard2 = deck.draw();
87
         Card playerCard2 = deck.draw();
88
         blackJackPlayer.addToHand(playerCard2);
88
         blackJackPlayer.addToHand(playerCard2);
89
 
89
 
90
         Card dealerCard2 = deck.draw();
90
         Card dealerCard2 = deck.draw();
91
         dealerHand.add(dealerCard2);
91
         dealerHand.add(dealerCard2);
92
+        System.out.println(dealerCard2);
92
 
93
 
93
         setJustDealt(true);
94
         setJustDealt(true);
94
     }
95
     }
98
     }
99
     }
99
 
100
 
100
     public void start() {
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
         // upon starting a new game, every player places a bet? make a loop???
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
     public void end() {
119
     public void end() {
126
                 break;
140
                 break;
127
             }
141
             }
128
         }
142
         }
129
-
130
     }
143
     }
131
 
144
 
132
     public int betAmount(int amount, BlackJackPlayer blackJackPlayer) {
145
     public int betAmount(int amount, BlackJackPlayer blackJackPlayer) {