瀏覽代碼

tried again

ThuyKhong 6 年之前
父節點
當前提交
d895d71af5

+ 8
- 1
src/main/java/io/zipcoder/casino/cardgames/BlackJack.java 查看文件

@@ -69,7 +69,7 @@ public class BlackJack extends CardGame implements Gamble {
69 69
 
70 70
             while (getSum(currentPlayer.getHand()) < 21) {
71 71
                 if (hitOrStand.equals("H")) {
72
-                    dealCards(currentPlayer, 1);
72
+                    dealCard(currentPlayer,1);
73 73
                 } else if (hitOrStand.equals("S")) {
74 74
                     break;
75 75
                 } else {
@@ -112,6 +112,13 @@ public class BlackJack extends CardGame implements Gamble {
112 112
         }
113 113
     }
114 114
 
115
+    public void dealCard(BlackJackPlayer p, int numberOfCards) {
116
+        for (int i = 0; i < numberOfCards; i++) {
117
+            Card card = deck.removeFirst();
118
+            p.getHand().add(card);
119
+        }
120
+    }
121
+
115 122
     public void placeBet() {
116 123
         bet = Console.getLongInput("Please enter your bet.");
117 124
     }

+ 1
- 1
src/main/java/io/zipcoder/casino/player/BlackJackPlayer.java 查看文件

@@ -2,7 +2,7 @@ package io.zipcoder.casino.player;
2 2
 
3 3
 import io.zipcoder.casino.cardgames.cards.CardHand;
4 4
 
5
-public class BlackJackPlayer extends Player{
5
+public class BlackJackPlayer{
6 6
     private CardHand hand;
7 7
     Player blackJackPlayer;
8 8
     private long bet;

+ 1
- 1
src/main/java/io/zipcoder/casino/utilities/Console.java 查看文件

@@ -113,7 +113,7 @@ public class Console {
113 113
          return userInput;
114 114
 
115 115
      }
116
-     public  static Long getLongInput(String prompt) {
116
+     public static Long getLongInput(String prompt) {
117 117
          Scanner scanner = new Scanner(System.in);
118 118
          println(prompt);
119 119
          Long userInput = scanner.nextLong();