|
@@ -1,6 +1,6 @@
|
1
|
1
|
package io.zipcoder.casino;
|
2
|
2
|
|
3
|
|
-public class BlackJack extends CardGames implements Gamble, Game{
|
|
3
|
+public class BlackJack extends CardGames {
|
4
|
4
|
int playerHand;
|
5
|
5
|
int dealerHand;
|
6
|
6
|
int currentBet;
|
|
@@ -12,41 +12,67 @@ public class BlackJack extends CardGames implements Gamble, Game{
|
12
|
12
|
playingBj = true;
|
13
|
13
|
}
|
14
|
14
|
|
15
|
|
-public BlackJack(Player player){
|
|
15
|
+ public BlackJack(Player player) {
|
16
|
16
|
|
17
|
|
-}
|
|
17
|
+ }
|
18
|
18
|
|
19
|
19
|
|
20
|
20
|
|
21
|
21
|
while(playingBJ ==true)
|
22
|
22
|
|
23
|
23
|
{
|
24
|
|
- currentBet = Console.numberFromString(Console.askForInput("How much would you like to bet?"));
|
|
24
|
+ Console.output("Welcome to BlackJack " + player.name + ". I am your dealer Vince and I am here to take your money!");
|
|
25
|
+ currentBet = Console.numberFromString(Console.askForInput("How much would you like to bet?"));
|
25
|
26
|
deck.deal();
|
26
|
27
|
if (dealerHand == 21) {
|
27
|
28
|
Console.output("Dealer has BlackJack! You lose!");
|
28
|
29
|
loseBet(currentBet);
|
29
|
30
|
currentBet = 0;
|
|
31
|
+ deck.deal();
|
30
|
32
|
} else if (playerHand == 21) {
|
31
|
|
- Console.output("Dealer has BlackJack! You lose!");
|
32
|
|
- winBet(currentBet);
|
|
33
|
+ Console.output("You have BlackJack! You win!");
|
|
34
|
+ winBet((currentBet * 3) / 2);
|
33
|
35
|
currentBet = 0;
|
|
36
|
+ deck.deal();
|
|
37
|
+
|
|
38
|
+ }
|
|
39
|
+ while (playerHand < 21) {
|
|
40
|
+ String action = Console.askForInput("Dealer is showing: " + "You have " + playerHand + ". Please enter 'hit' or 'stay'.");
|
|
41
|
+ if (action.equals("hit")) {
|
|
42
|
+ drawCard();
|
|
43
|
+ cardValue += playerHand;
|
|
44
|
+ if (playerHand > 21) {
|
|
45
|
+ Console.output("You have " + playerHand + " and bust, you suck!");
|
|
46
|
+ loseBet(currentBet);
|
|
47
|
+ currentBet = 0;
|
|
48
|
+ }
|
|
49
|
+ } else if (action.equals("stay")) {
|
|
50
|
+ break;
|
|
51
|
+ }
|
|
52
|
+ }
|
|
53
|
+ while (dealerHand < 17 && dealerHand < 21) {
|
|
54
|
+ Console.output("Dealer has " + dealerHand + " and hits.");
|
|
55
|
+ drawcard();
|
|
56
|
+ cardValue += dealerHand;
|
|
57
|
+ if (dealerHand > 21) {
|
|
58
|
+ Console.output("Dealer has " + dealerHand + " and busts, you win!");
|
|
59
|
+ winBet(currentBet);
|
|
60
|
+ currentBet = 0;
|
|
61
|
+ } else if (dealerHand >= 17 && dealerHand < 21) {
|
|
62
|
+ Console.output("Dealer has " + dealerHand + " and stands.");
|
|
63
|
+ }
|
34
|
64
|
}
|
35
|
65
|
|
36
|
66
|
|
37
|
67
|
|
|
68
|
+ }
|
38
|
69
|
|
|
70
|
+}
|
39
|
71
|
|
40
|
72
|
|
41
|
|
- String action = Console.askForInput("Do you want to hit or stay?");
|
42
|
73
|
|
43
|
|
- if (action.equals("hit")) {
|
44
|
74
|
|
45
|
|
- }
|
46
|
|
- if (action.equals("stay"))
|
47
|
75
|
|
48
|
76
|
|
49
|
|
- }
|
50
|
77
|
|
51
|
78
|
|
52
|
|
-}
|