Browse Source

blackjack .02

Vincent Sima 6 years ago
parent
commit
d513decc01

+ 36
- 13
src/main/java/io/zipcoder/casino/BlackJack.java View File

@@ -1,29 +1,52 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
-public class BlackJack {
4
-int playerHand;
5
-int dealerHand;
6
-int currentBet;
7
-boolean playingBJ = false;
8
-CardDeck deck = new CardDeck();
9
-
10
-public void start(){
11
-    playingBj = true;
3
+public class BlackJack extends CardGames implements Gamble, Game{
4
+    int playerHand;
5
+    int dealerHand;
6
+    int currentBet;
7
+    boolean playingBJ = false;
8
+    CardDeck deck = new CardDeck();
9
+    Player player;
10
+
11
+    public void start() {
12
+        playingBj = true;
13
+    }
14
+
15
+public BlackJack(Player player){
16
+
12 17
 }
13 18
 
14 19
 
15
-while(playingBJ == true){
16
-    deck.deal();
17
-    Cons
18 20
 
21
+while(playingBJ ==true)
22
+
23
+    {
24
+        currentBet =  Console.numberFromString(Console.askForInput("How much would you like to bet?"));
25
+        deck.deal();
26
+        if (dealerHand == 21) {
27
+            Console.output("Dealer has BlackJack! You lose!");
28
+            loseBet(currentBet);
29
+            currentBet = 0;
30
+        } else if (playerHand == 21) {
31
+            Console.output("Dealer has BlackJack! You lose!");
32
+            winBet(currentBet);
33
+            currentBet = 0;
34
+        }
19 35
 
20 36
 
21
-    }
22 37
 
23 38
 
24 39
 
25 40
 
41
+        String action = Console.askForInput("Do you want to hit or stay?");
26 42
 
43
+        if (action.equals("hit")) {
44
+
45
+        }
46
+        if (action.equals("stay"))
47
+
48
+
49
+    }
27 50
 
28 51
 
29 52
 }

+ 3
- 1
src/main/java/io/zipcoder/casino/Console.java View File

@@ -11,10 +11,12 @@ public class Console {
11 11
         return Integer.toString(num);
12 12
     }
13 13
 
14
+
15
+
14 16
     public static String askForInput(String thingToAsk) {
15 17
         System.out.println(thingToAsk);
16 18
         Scanner scan = new Scanner(System.in);
17
-        return scan.nextLine();
19
+        return scan.nextLine().toLowerCase();
18 20
     }
19 21
 
20 22
     public static String output(String output) {

+ 4
- 4
src/main/java/io/zipcoder/casino/Gamble.java View File

@@ -4,11 +4,11 @@ public interface Gamble {
4 4
 
5 5
 
6 6
 
7
-     int currentBet;
7
+     int currentBet = 0;
8
+     void bet(int bet);
9
+     void winBet(int currentBet);
10
+     void loseBet(int currentBet);
8 11
 
9
-     void bet(int);
10
-     void winBet(Player);
11
-     void loseBet(Player);
12 12
 
13 13
 
14 14