Ver código fonte

Merge branch 'working' into blackjack

ThuyKhong 6 anos atrás
pai
commit
633cf12d2c

+ 25
- 9
src/main/java/io/zipcoder/casino/Casino.java Ver arquivo

@@ -14,12 +14,16 @@ public class Casino {
14 14
     Players players = Players.getInstance();
15 15
     Console console = new Console();
16 16
     boolean continueGame = true;
17
+    int numberOfPlayers = 0;
18
+    boolean kickedOut = false;
17 19
 
18 20
     public static void main(String[] args) {
19 21
         Casino casino = new Casino();
22
+        Console console = new Console();
20 23
 
21 24
 //before game
22 25
         casino.enterPlayers();
26
+
23 27
         while (casino.continueGame == true) {
24 28
             //ADD LOOP
25 29
             casino.chooseTable();
@@ -27,17 +31,21 @@ public class Casino {
27 31
 //after game
28 32
             casino.printBalance();
29 33
             casino.bootPlayer();
34
+            if (casino.kickedOut) console.kickedOut();
35
+
36
+            casino.continueGame = casino.promptContinue();
30 37
         }
31 38
     }
32 39
 
33 40
     public void enterPlayers() {
34
-        int numberOfPlayers = getNumberOfPlayers();
41
+        numberOfPlayers = getNumberOfPlayers();
35 42
         String playerNames = "";
36 43
         playerNames = getPlayerNames(numberOfPlayers, playerNames);
37
-        console.println(playerNames + "THANK YOU FOR JOINING US");
44
+        console.println("\n"+ playerNames + "THANK YOU FOR JOINING US");
38 45
     }
39 46
 
40 47
     private String getPlayerNames(int numberOfPlayers, String playerNames) {
48
+        console.println("");
41 49
         for (int i = 1; i <= numberOfPlayers; i++) {
42 50
           String nameOfPlayer = console.getStringInput("PLAYER " + i + ": WHAT IS YOUR NAME?");
43 51
           players.addPlayer(new Player(nameOfPlayer));
@@ -47,8 +55,10 @@ public class Casino {
47 55
     }
48 56
 
49 57
     private int getNumberOfPlayers() {
50
-        return console.getIntegerInput("WELCOME TO EPSILON CASINO, CALLED \"ALMOST A CASINO\" ON YELP\n" +
51
-                  "PLEASE ENTER A NUMBER OF PLAYERS.");
58
+        return console.getIntegerInput("*********************************\n" +
59
+                "    WELCOME TO EPSILON CASINO\n---------------------------------\n" +
60
+                "CALLED \"ALMOST A CASINO\" ON YELP\n*********************************\n" +
61
+                "\nPLEASE ENTER A NUMBER OF PLAYERS.");
52 62
     }
53 63
 
54 64
     public void chooseTable() {
@@ -77,11 +87,14 @@ public class Casino {
77 87
     public void bootPlayer() {
78 88
         // If player balance is 0, player game over
79 89
         for (int i = 0; i < players.getPlayers().size(); i++) {
80
-          if(players.getPlayers().get(i).getChipBalance()<=0){
81
-            console.println(players.getPlayers().get(i).getName() + ", YOU ARE BROKE. GTFO, PEASANT.");
90
+          if(players.getPlayers().get(i).getChipBalance()<1){
91
+            console.println(players.getPlayers().get(i).getName() + ", YOU ARE BROKE. GTFO, PEASANT.\n");
82 92
             players.removePlayer(players.getPlayers().get(i));
93
+            i = i-1;
94
+            kickedOut = true;
83 95
           }
84 96
         }
97
+        this.numberOfPlayers = players.getPlayers().size();
85 98
     }
86 99
 
87 100
     public void printBalance() {
@@ -90,9 +103,12 @@ public class Casino {
90 103
       }
91 104
     }
92 105
 
93
-    public void promptContinue() {
94
-        String continueChoice = console.getStringInput("Would you like to play another game? Y/N");
95
-        if (continueChoice.equalsIgnoreCase("n")) continueGame = false;
106
+    public boolean promptContinue() {
107
+        if (numberOfPlayers > 0) {
108
+            String continueChoice = console.getStringInput("Would you like to play another game? Y/N");
109
+            if (continueChoice.equalsIgnoreCase("n")) return false;
110
+        } else return false;
111
+        return true;
96 112
     }
97 113
 
98 114
 

+ 49
- 33
src/main/java/io/zipcoder/casino/cardgames/BlackJack.java Ver arquivo

@@ -14,11 +14,12 @@ import java.util.ArrayList;
14 14
 
15 15
 public class BlackJack extends CardGame implements Gamble {
16 16
 
17
+    CardHand dealerHand = new CardHand();
18
+    boolean continueGame = true;
17 19
     private Deck deck = new Deck();
18 20
     private ArrayList<BlackJackPlayer> blackJackPlayers = new ArrayList<>();
19
-    CardHand dealerHand = new CardHand();
20 21
 
21
-    public BlackJack(){
22
+    public BlackJack() {
22 23
         announceGameChoice();
23 24
         readyPlayers();
24 25
         placePlayerBets();
@@ -33,13 +34,12 @@ public class BlackJack extends CardGame implements Gamble {
33 34
     }
34 35
 
35 36
     @Override
36
-    public void runGame(){
37
-        for(int i = 0; i < blackJackPlayers.size(); i++){
38
-            play(blackJackPlayers.get(i),blackJackPlayers.get(i).getBet());
37
+    public void runGame() {
38
+        for (int i = 0; i < blackJackPlayers.size(); i++) {
39
+            play(blackJackPlayers.get(i), blackJackPlayers.get(i).getBet());
39 40
         }
40 41
     }
41 42
 
42
-    boolean continueGame = true;
43 43
     public void play(BlackJackPlayer currentPlayer, long bet) {
44 44
         boolean dealerWins = false;
45 45
 
@@ -47,16 +47,18 @@ public class BlackJack extends CardGame implements Gamble {
47 47
         dealerWins = dealerCheck(); //TO ADD: if both player and dealer have blackjack, player keeps bet
48 48
         if (dealerWins == true) continueGame = false; // all players lose
49 49
 
50
-        while (continueGame == true) {
50
+        while (continueGame) {
51 51
             dealerDraw();
52 52
 
53
-            Console.println("Dealer is showing a " + dealerHand.get(0).getCard()); // dealer reveals upcard
53
+            Console.println("\nDealer is showing a " + dealerHand.get(0).getCard()); // dealer reveals upcard
54 54
 
55 55
             playersTurn();
56 56
 
57
-            if (blackJackPlayers.size() < 1) continueGame = false;
57
+            continueGame = evalBusts();
58
+            if (!continueGame) break;
58 59
 
59 60
             continueGame = dealersTurn(); // IMPLEMENT: if dealer loses, all players should receive payout
61
+            if (!continueGame) break;
60 62
 
61 63
             continueGame = evalWinner();
62 64
         }
@@ -67,9 +69,19 @@ public class BlackJack extends CardGame implements Gamble {
67 69
 
68 70
     }
69 71
 
72
+    private boolean evalBusts() {
73
+        int bustCounter = 0;
74
+        for (int i = 0; i < blackJackPlayers.size(); i++) {
75
+            if (blackJackPlayers.get(i).isPlayerBust()) bustCounter++;
76
+        }
77
+        if (blackJackPlayers.size() == bustCounter) {
78
+            return false;
79
+        } else return true;
80
+    }
81
+
70 82
     public boolean dealerCheck() {
71
-        if (getSum(dealerHand) == 21){
72
-            Console.println("Dealer has " +  dealerHand.display());
83
+        if (getSum(dealerHand) == 21) {
84
+            Console.println("Dealer has " + dealerHand.display());
73 85
             Console.println("Dealer has blackjack. Dealer wins.");
74 86
             return true;
75 87
         }
@@ -82,14 +94,14 @@ public class BlackJack extends CardGame implements Gamble {
82 94
     }
83 95
 
84 96
     public void dealerCollectAll() {
85
-        for (BlackJackPlayer p: this.blackJackPlayers){ // collects bet from all players
97
+        for (BlackJackPlayer p : this.blackJackPlayers) { // collects bet from all players
86 98
             evaluateBet(p.getP(), -p.getBet());
87 99
         }
88 100
     }
89 101
 
90 102
     public void payoutAll() {
91
-        for (BlackJackPlayer p: this.blackJackPlayers){ // collects bet from all players
92
-            long winnings = p.getBet()*2;
103
+        for (BlackJackPlayer p : this.blackJackPlayers) { // collects bet from all players
104
+            long winnings = p.getBet() * 2;
93 105
             evaluateBet(p.getP(), winnings);
94 106
         }
95 107
     }
@@ -99,7 +111,7 @@ public class BlackJack extends CardGame implements Gamble {
99 111
     }
100 112
 
101 113
     public void placePlayerBets() {
102
-        for (BlackJackPlayer p: this.blackJackPlayers){ //gets bet from each player
114
+        for (BlackJackPlayer p : this.blackJackPlayers) { //gets bet from each player
103 115
             Console.println(p.getName());
104 116
             placeBet(p);
105 117
         }
@@ -114,10 +126,12 @@ public class BlackJack extends CardGame implements Gamble {
114 126
         for (BlackJackPlayer currentPlayer : blackJackPlayers) {
115 127
             if (getSum(dealerHand) == getSum(currentPlayer.getHand())) {
116 128
                 Console.println(String.format("Against %s's hand, dealer wins on a tie.", currentPlayer.getP().getName()));
117
-                evaluateBet(currentPlayer.getP(), -currentPlayer.getBet());
129
+                dealerCollect(currentPlayer);
130
+            } else if (getSum(currentPlayer.getHand()) > 21) {
131
+                dealerCollect(currentPlayer);
118 132
             } else if (getSum(dealerHand) <= 21 && getSum(dealerHand) > getSum(currentPlayer.getHand())) {
119 133
                 Console.println(String.format("Against %s's hand, dealer wins.", currentPlayer.getP().getName()), currentPlayer.getP().getName());
120
-                evaluateBet(currentPlayer.getP(), -currentPlayer.getBet());
134
+                dealerCollect(currentPlayer);
121 135
             } else {
122 136
                 Console.println(String.format("%s, you win!", currentPlayer.getP().getName()));
123 137
                 evaluateBet(currentPlayer.getP(), currentPlayer.getBet());
@@ -136,7 +150,7 @@ public class BlackJack extends CardGame implements Gamble {
136 150
         }
137 151
 
138 152
         if (getSum(dealerHand) > 21) {
139
-            Console.println("Dealer busted. You win.");
153
+            Console.println("\nDealer busted. You all win!");
140 154
             payoutAll();
141 155
             return false;
142 156
         }
@@ -150,7 +164,7 @@ public class BlackJack extends CardGame implements Gamble {
150 164
         for (int i = 0; i < blackJackPlayers.size(); i++) {
151 165
             currentPlayer = blackJackPlayers.get(i);
152 166
 
153
-            Console.println(String.format("%s, you're up!", currentPlayer.getP().getName()));
167
+            Console.println(String.format("\n%s, you're up!", currentPlayer.getP().getName()));
154 168
             displaySumPlayerHand(currentPlayer);
155 169
 
156 170
             hitOrStand(currentPlayer);
@@ -158,10 +172,9 @@ public class BlackJack extends CardGame implements Gamble {
158 172
     }
159 173
 
160 174
     private boolean playerBust(BlackJackPlayer currentPlayer) {
161
-        if (getSum(currentPlayer.getHand()) > 21){
162
-            Console.println(currentPlayer.getP().getName() + " busted. House wins.");
163
-            dealerCollect(currentPlayer);
164
-            blackJackPlayers.remove(currentPlayer);
175
+        if (getSum(currentPlayer.getHand()) > 21) {
176
+            Console.println("\n"+currentPlayer.getP().getName() + " busted. House wins.");
177
+//            blackJackPlayers.remove(currentPlayer);
165 178
             return false;
166 179
         }
167 180
         return true;
@@ -174,11 +187,11 @@ public class BlackJack extends CardGame implements Gamble {
174 187
     public void hitOrStand(BlackJackPlayer currentPlayer) {
175 188
 
176 189
         while (getSum(currentPlayer.getHand()) < 21) {
177
-            String hitOrStand = Console.getStringInput(currentPlayer.getP().getName() + ", do you want to Hit or Stand?\nEnter H for Hit or S for Stand");
190
+            String hitOrStand = Console.getStringInput(String.format("\n%s, do you want to Hit or Stand?\nEnter H for Hit or S for Stand", currentPlayer.getP().getName()));
178 191
 
179 192
             if (hitOrStand.equalsIgnoreCase("H")) {
180 193
                 dealCards(currentPlayer, 1);
181
-                Console.println(currentPlayer.getP().getName() + ", you have been dealt %s.", currentPlayer.getHand().get(currentPlayer.getHand().size()-1).getCard());
194
+                Console.println( "\n%s, you have been dealt %s.", currentPlayer.getP().getName(), currentPlayer.getHand().get(currentPlayer.getHand().size() - 1).getCard());
182 195
                 displaySumPlayerHand(currentPlayer);
183 196
                 playerBust(currentPlayer);
184 197
             } else if (hitOrStand.equalsIgnoreCase("S")) {
@@ -196,8 +209,8 @@ public class BlackJack extends CardGame implements Gamble {
196 209
             if (getSum(p.getHand()) == 21) {
197 210
                 Console.println(p.getP().getName() + ", you have " + p.getHand().display());
198 211
                 Console.println(p.getP().getName() + ", you have blackjack. You win!");
199
-                evaluateBet(p.getP(), p.getBet());
200
-                blackJackPlayers.remove(i);
212
+//                evaluateBet(p.getP(), p.getBet());
213
+//                blackJackPlayers.remove(i);
201 214
             }
202 215
         }
203 216
     }
@@ -205,7 +218,7 @@ public class BlackJack extends CardGame implements Gamble {
205 218
     @Override
206 219
     public void dealCards(int numberOfCards) {
207 220
         Console.println("The dealer is dealing cards to the players.");
208
-        for(BlackJackPlayer p: blackJackPlayers){ //deal 2 cards to each player
221
+        for (BlackJackPlayer p : blackJackPlayers) { //deal 2 cards to each player
209 222
             for (int i = 0; i < numberOfCards; i++) {
210 223
                 Card card = deck.removeFirst();
211 224
                 p.getHand().add(card);
@@ -230,7 +243,7 @@ public class BlackJack extends CardGame implements Gamble {
230 243
     }
231 244
 
232 245
     public void evaluateBet(Player player, long payout) {
233
-        player.setChipBalance(player.getChipBalance()+payout);
246
+        player.setChipBalance(player.getChipBalance() + payout);
234 247
     }
235 248
 
236 249
 
@@ -240,7 +253,7 @@ public class BlackJack extends CardGame implements Gamble {
240 253
         return card;
241 254
     }
242 255
 
243
-    public int  getSum(CardHand cardHand) {
256
+    public int getSum(CardHand cardHand) {
244 257
         int cardSum = 0;
245 258
         boolean ace = false;
246 259
 
@@ -255,19 +268,22 @@ public class BlackJack extends CardGame implements Gamble {
255 268
             }
256 269
             cardSum = cardSum + cardValue;
257 270
         }
258
-        if (cardHand.size() == 2 && ace && cardSum + 10 == 21) {
271
+        if (cardHand.size() == 2 && ace && cardSum + 10 <= 21) {
259 272
             cardSum = cardSum + 10;
260 273
         }
261 274
         return cardSum;
262 275
     }
263 276
 
264
-    public void revealCard(){
277
+    public void revealCard() {
265 278
         Card newCard = drawCard();
266 279
         Console.println("Dealer drew a " + newCard.getCardValue() + " of " + newCard.getSuit().getCardGraphic());
267 280
         dealerHand.add(newCard);
268 281
     }
269 282
 
270 283
     @Override
271
-    public void promptContinue(){};
284
+    public void promptContinue() {
285
+    }
286
+
287
+    ;
272 288
 
273 289
 }

+ 111
- 63
src/main/java/io/zipcoder/casino/cardgames/GoFish.java Ver arquivo

@@ -1,31 +1,19 @@
1 1
 package io.zipcoder.casino.cardgames;
2 2
 
3
-import io.zipcoder.casino.utilities.abstracts.CardGame;
4
-import io.zipcoder.casino.utilities.containers.Deck;
5 3
 import io.zipcoder.casino.player.GoFishPlayer;
6 4
 import io.zipcoder.casino.player.Player;
7 5
 import io.zipcoder.casino.player.Players;
6
+import io.zipcoder.casino.utilities.Card;
7
+import io.zipcoder.casino.utilities.Console;
8
+import io.zipcoder.casino.utilities.abstracts.CardGame;
9
+import io.zipcoder.casino.utilities.containers.Deck;
8 10
 
9 11
 import java.util.ArrayList;
10 12
 
11 13
 public class GoFish extends CardGame {
12 14
     private static Deck drawPile = new Deck();
13
-    // Change Deck to deque;
14 15
     private ArrayList<GoFishPlayer> goFishPlayers = new ArrayList<>();
15
-
16
-    public static void main(String[] args) {
17
-        System.out.println();
18
-    }
19
-
20
-    public GoFish() {
21
-        readyPlayers();
22
-        runGame();
23
-    }
24
-
25
-    @Override
26
-    public void runGame(){
27
-
28
-    }
16
+//    private int numberOfCards;
29 17
 
30 18
     public void readyPlayers() {
31 19
         for (Player player : Players.getInstance().getPlayers()) {
@@ -33,11 +21,20 @@ public class GoFish extends CardGame {
33 21
         }
34 22
     }
35 23
 
36
-    public int getNumberOfCards() {      //generate numberOfCards param for below based on number of players
24
+    @Override
25
+    public void runGame() {                                 // run the game as long as the drawPile is more than 0 cards
26
+        while (drawPile.size() >= 0) {
27
+            for (int j = 0; j < goFishPlayers.size(); j++) {
28
+                playGoFish();
29
+            }
30
+        }
31
+    }
32
+
33
+    public int getStartingCards() {                 //generate numberOfCards param for below based on number of players
37 34
         int numberOfCards;
38
-        if (goFishPlayers.size() <= 3) {  //RULES: For 3 players or less, deal each player 7 cards;
35
+        if (goFishPlayers.size() <= 3) {            //RULES: For 3 players or less, deal each player 7 cards;
39 36
             numberOfCards = 7;
40
-        } else {                           //RULES contd: if more than three players, deal 5 cards each.
37
+        } else {                                    //RULES contd: if more than three players, deal 5 cards each.
41 38
             numberOfCards = 5;
42 39
         }
43 40
         return numberOfCards;
@@ -45,56 +42,107 @@ public class GoFish extends CardGame {
45 42
 
46 43
     @Override
47 44
     public void dealCards(Player player, int numberOfCards) {
48
-        // dealPile = dealPile - numberOfCards;
45
+//        numberOfCards = getStartingCards();
46
+//        GoFishPlayer fishie = (GoFishPlayer) player;                    // depending on how many players
47
+//        for (int i = 0; i < numberOfCards; i++) {
48
+//            Card card = drawPile.removeFirst();
49
+//            fishie.getHand().add(card);
50
+//        }
49 51
     }
50 52
 
51 53
     @Override
52 54
     public void dealCards(int numberOfCards) {
55
+        numberOfCards = getStartingCards();
56
+        for (GoFishPlayer p : goFishPlayers) {
57
+            for (int i = 0; i < numberOfCards; i++) {
58
+                Card card = drawPile.removeFirst();
59
+                p.getHand().add(card);
60
+            }
61
+        }
62
+    }
53 63
 
64
+    public GoFish() {
65
+        readyPlayers();
66
+        dealCards(getStartingCards());
67
+        runGame();
54 68
     }
55 69
 
56 70
     @Override
57
-    public void promptContinue(){};
58
-    //
59
-    public void updateDrawPile() {
60
-
61
-//    public void play() {
62
-//        for (int i = 0; i }
63
-
64
-//    int setsCount;
65
-
66
-
67
-        //while (drawPile > 0) {
68
-        //public void questionPlayer(String cardRank, Player player) {
69
-        //start w/ player
70
-        //for (deck.size aka (52 cards - numOfCards per player))
71
-        //askPlayerQuestion(); Prompt w/ question of who to ask [console output?]
72
-        //take userInput [console input?]
73
-        //askPlayerCard(); Prompt w/question of what card (rank) to look for [console output?]
74
-        //take userInput[console input?]
75
-        //for cardHand(chosen player)
76
-        //evalCards(userInput): If userInput.equals(card[i].cardGetValue)
77
-        //swap();
78
-        //repeat until userInput != cardGetValue
79
-        //else
80
-        //goFish(); draw a card from Deck - (deck - 1)
81
-        //move to next player;
82
-        //checkSets: run through each cardHand and looks for 4 of a kind;
83
-        //if found, setsCount++;
84
-
85
-
86
-//    public void evalCards() {
87
-//        //for cards in dealerHand:
88
-////        swap cards or go fish
89
-//    }
90
-//
91
-//    public void goFish() {
92
-//        //pull from top of deck
93
-//    }
94
-//
95
-//    public void checkSets() {
96
-//        // check if 4 in dealerHand have same value
97
-//    }
71
+    public void promptContinue() {
72
+    }                                     //WHAT??
73
+
74
+
75
+    public void playGoFish() {
76
+            askForOpponent();
77
+            searchCard();
78
+            checkCards();
79
+            checkSets();
80
+    }
81
+
82
+    public String askForOpponent() {
83
+        String opponent = Console.getStringInput("Which player would you like to question?");
84
+        return opponent;
85
+    }
86
+
87
+    public Integer searchCard() {
88
+        Integer wantedCard = Console.getIntegerInput("Which card would you like to request?");
89
+        return wantedCard;
90
+    }
91
+
92
+    public void checkCards() {
93
+        String opponent = askForOpponent();
94
+        GoFishPlayer fishie = new GoFishPlayer();
95
+        for (int i = 0; i < goFishPlayers.size(); i++) {
96
+            if (opponent.equals(goFishPlayers.get(i).getName())) {
97
+                Console.println(fishie.getName() + " has " + fishie.getHand().display());  //hopefully this prints out
98
+                for (int j = 0; j < goFishPlayers.get(i).getHand().size(); j++) {
99
+                    while (searchCard().equals(goFishPlayers.get(i).getHand().get(j).getCardValue())) {
100
+                        Console.println("Nice job!");
101
+                        fishie.getHand().add(goFishPlayers.get(i).getHand().get(j));
102
+                        goFishPlayers.get(i).getHand().remove(j);
103
+                        askForOpponent();                                   //need this?
104
+                        searchCard();                                       //need this?
105
+                    }
106
+                    fish();
107
+                }
108
+            }
109
+        }
110
+    }
111
+
112
+
113
+    public void fish() {
114
+        GoFishPlayer player = new GoFishPlayer();
115
+        player.getHand().add(drawPile.removeFirst());
116
+        Console.println("Lame. Go Fish loser \"\\uD83D\\uDC1F\"");
117
+    }
118
+
119
+
120
+    public void checkSets() {                                               // help. lost. trying to set aside the sets
121
+//        GoFishPlayer player = new GoFishPlayer();
122
+        for (int i = 0; i < goFishPlayers.size(); i++) {
123
+            GoFishPlayer currentPlayer = goFishPlayers.get(i);
124
+            for (int j = 0; j < currentPlayer.getHand().size(); j++) {
125
+                int set = 0;
126
+                for (int k = 1; k < currentPlayer.getHand().size(); k++) {
127
+                    if (currentPlayer.getHand().get(j).getCardValue() == currentPlayer.getHand().get(k).getCardValue()) {
128
+                        set++;
129
+                    }
130
+                }
131
+                if (set>=4) {
132
+                    int setCount = currentPlayer.getSetCount();
133
+                    int newSetCount = setCount += 1;
134
+                    currentPlayer.setSetCount(newSetCount);
135
+                }
136
+//                    setCount.put();
137
+//                }
138
+//                goFishPlayers.get(i).getHand();
139
+//                if (setCount.containsKey(goFishPlayers.get(i).getHand().get().getCardValue())))
140
+            }
141
+            {
142
+
143
+            }
144
+        }
145
+
98 146
 
99 147
     }
100
-}
148
+}

+ 29
- 25
src/main/java/io/zipcoder/casino/dicegames/Craps.java Ver arquivo

@@ -1,6 +1,5 @@
1 1
 package io.zipcoder.casino.dicegames;
2 2
 
3
-import io.zipcoder.casino.player.BlackJackPlayer;
4 3
 import io.zipcoder.casino.utilities.Console;
5 4
 import io.zipcoder.casino.utilities.interfaces.Gamble;
6 5
 import io.zipcoder.casino.player.CrapsPlayer;
@@ -18,6 +17,7 @@ public class Craps extends DiceGame implements Gamble {
18 17
     public Craps() {
19 18
         announceGameChoice();
20 19
         readyPlayers();
20
+        //promptBets();
21 21
         runGame();
22 22
     }
23 23
     //for test purposes
@@ -40,15 +40,8 @@ public class Craps extends DiceGame implements Gamble {
40 40
         }
41 41
     }
42 42
 
43
-    public void placeBet() {
44
-        this.bet = console.integerInputSameLine("Enter your bet: ");
45
-    }
46
-
47
-    @Override
48 43
     public void placeBet(Player player) {
49
-        BlackJackPlayer blackJackPlayer = (BlackJackPlayer) player;
50
-        long bet = Console.getLongInput("Please enter your bet.");
51
-        blackJackPlayer.setBet(bet);
44
+        bet = console.integerInputSameLine("Enter your bet: ");
52 45
     }
53 46
 
54 47
     public void evaluateBet(Player player, long payout) {
@@ -56,28 +49,34 @@ public class Craps extends DiceGame implements Gamble {
56 49
     }
57 50
 
58 51
     public void play(CrapsPlayer currentPlayer) {
59
-        placeBet();
52
+        placeBet(currentPlayer);
53
+        int sum = rollDie(2);
60 54
 
61 55
         promptEnterKey("roll dice");
56
+        printRollSum(sum);
62 57
 
63
-        int sum = rollDie(2);
64
-
65
-        console.println("Your roll sum equals: " + sum);
58
+        simulateCraps(currentPlayer, sum);
59
+    }
66 60
 
61
+    private void simulateCraps(CrapsPlayer currentPlayer, int sum) {
67 62
         if (sum == 7 || sum == 11) {
68 63
             evalWin(currentPlayer.getP());
69 64
         } else if (sum == 2 || sum == 3 || sum == 12) {
70 65
             evalLoss(currentPlayer.getP());
71 66
         } else {
72
-            int point = sum;
73
-            do {
74
-                printRollAgain(point);
75
-                sum = rollDie(2);
76
-                evalReRoll(currentPlayer, sum , point);
77
-            } while (sum != point && sum != 7);
67
+            rollForPoint(currentPlayer, sum);
78 68
         }
79 69
     }
80 70
 
71
+    private void rollForPoint(CrapsPlayer currentPlayer, int sum) {
72
+        int point = sum;
73
+        do {
74
+            printRollAgain(point);
75
+            sum = rollDie(2);
76
+            evalReRoll(currentPlayer, sum , point);
77
+        } while (sum != point && sum != 7);
78
+    }
79
+
81 80
     public void print(){
82 81
         for(int i = 0; i < crapsPlayers.size(); i++){
83 82
             System.out.println(crapsPlayers.get(i).getP().getChipBalance());
@@ -85,14 +84,13 @@ public class Craps extends DiceGame implements Gamble {
85 84
     }
86 85
 
87 86
     public void printRollAgain(int point){
88
-        console.println("\n--------------------");
89
-        console.println("Point to roll for: " + point);
90
-        console.println("--------------------");
87
+        console.println("\n=====================" +
88
+                "\nPoint to roll for: " + point + "\n=====================");
91 89
         promptEnterKey("roll again");
92 90
     }
93 91
 
94 92
     public void evalReRoll(CrapsPlayer currentPlayer, int sum, int point){
95
-        console.println("You rolled a " + sum);
93
+        printRollSum(sum);
96 94
         if (sum == 7) {
97 95
             evalLoss(currentPlayer.getP());
98 96
         } else if (sum == point) {
@@ -100,6 +98,11 @@ public class Craps extends DiceGame implements Gamble {
100 98
         }
101 99
     }
102 100
 
101
+    private void printRollSum(int sum) {
102
+        console.println("------------------------\n" +
103
+                "Your roll sum equals: " + sum + " \n------------------------");
104
+    }
105
+
103 106
     public void evalLoss(Player player){
104 107
         console.println("\n*********\nYOU LOSE!\n*********\n");
105 108
         evaluateBet(player, -bet);
@@ -116,9 +119,10 @@ public class Craps extends DiceGame implements Gamble {
116 119
     }
117 120
 
118 121
     public void promptEnterKey(String str){
119
-        String input = console.getStringInput("\nPress \"ENTER\" to " + str);
122
+        String input = console.getStringInput("\n>> " +
123
+                "Press \"ENTER\" to " + str);
120 124
     }
121 125
 
122 126
     @Override
123
-    public void promptContinue(){};
127
+    public void promptContinue(){}
124 128
 }

+ 5
- 0
src/main/java/io/zipcoder/casino/player/BlackJackPlayer.java Ver arquivo

@@ -6,6 +6,11 @@ public class BlackJackPlayer extends Player{
6 6
     private CardHand hand;
7 7
     Player blackJackPlayer;
8 8
     private long bet;
9
+    boolean playerBust = false;
10
+
11
+    public boolean isPlayerBust() {
12
+        return playerBust;
13
+    }
9 14
 
10 15
     public long getBet() {
11 16
         return bet;

+ 1
- 0
src/main/java/io/zipcoder/casino/player/CrapsPlayer.java Ver arquivo

@@ -20,4 +20,5 @@ public class CrapsPlayer extends Player {
20 20
     public long getBet() {
21 21
         return bet;
22 22
     }
23
+    public void setBet(long bet) { this.bet = bet;}
23 24
 }

+ 14
- 0
src/main/java/io/zipcoder/casino/player/GoFishPlayer.java Ver arquivo

@@ -4,11 +4,25 @@ import io.zipcoder.casino.utilities.containers.CardHand;
4 4
 
5 5
 public class GoFishPlayer extends Player{
6 6
     private CardHand hand;
7
+    int setCount = 0;
8
+
9
+    public int getSetCount() {
10
+        return setCount;
11
+    }
12
+
13
+    public void setSetCount(int setCount) {
14
+        this.setCount = setCount;
15
+    }
7 16
 
8 17
     Player goFishPlayer;
9 18
 
10 19
     public GoFishPlayer(Player player) {
11 20
         this.goFishPlayer = player;
21
+        this.hand = new CardHand();
22
+    }
23
+
24
+    public GoFishPlayer() {
25
+
12 26
     }
13 27
 
14 28
     public Player getP() {

+ 93
- 9
src/main/java/io/zipcoder/casino/utilities/Console.java Ver arquivo

@@ -1,8 +1,5 @@
1 1
 package io.zipcoder.casino.utilities;
2 2
 
3
-import io.zipcoder.casino.Casino;
4
-
5
-import java.awt.peer.SystemTrayPeer;
6 3
 import java.util.Scanner;
7 4
 
8 5
 public class Console {
@@ -104,7 +101,7 @@ public class Console {
104 101
 
105 102
     public static void printWcarrot(String output){
106 103
         System.out.println(output);
107
-        System.out.print(">");
104
+        System.out.print("> ");
108 105
     }
109 106
 
110 107
 
@@ -114,7 +111,7 @@ public class Console {
114 111
         String userInput = scanner.nextLine();
115 112
         return userInput;
116 113
       }
117
-     public Integer getIntegerInput(String prompt){
114
+     public static Integer getIntegerInput(String prompt){
118 115
          Scanner scanner = new Scanner(System.in);
119 116
          println(prompt);
120 117
          int userInput = scanner.nextInt();
@@ -140,14 +137,101 @@ public class Console {
140 137
     }
141 138
 
142 139
     public Integer getGameChoice() {
143
-        println("GAME LIST\n");
140
+        println("\n================");
141
+        println("GAME LIST");
142
+        println("----------------");
144 143
         println("1. CRAPS\n");
145 144
         println("2. BLACK JACK\n");
146
-        println("3. GO FISH\n");
147
-        println("CHOOSE TABLE\n");
148
-        return getIntegerInput("");
145
+        println("3. GO FISH");
146
+        println("================");
147
+        return getIntegerInput("\nCHOOSE TABLE");
149 148
     }
150 149
 
150
+    public void kickedOut() {
151
+
152
+        System.out.print("                `!(z$$#####$%+!`                                                   `!!(\"t\"``.\n" +
153
+                "             -*$$j\"+!!(!+*\"J$###j                                                  !\"\"!!.*\"\"#\"!.\n" +
154
+                "           !3\"! !!I$3I\"!!!'   .!!$.                                             '\"(!' .$I(%*!*!#!\n" +
155
+                "         !%!.!$#%(!              '3(             '                            `J\"         `''3\"!I\"\n" +
156
+                "        (+.\"#3!'!(\"**!+!!!         !%.           $*                          .#!    !`!!!       .j#.\n" +
157
+                "       .!!#\".!!!'                   `$'          !#    !                     ut  '!*!*!(\"*!    !#!`\"`\n" +
158
+                "         $\"    .!!!(\"!!!`      '%##\"..$     .!    #.   $                     #(  !!!!!\"!!'`    \"!`..%\n" +
159
+                "       `$(   !!\"!\"$&\"*\"!       3` !##!%      !\"   !\"   #                     #( $! !!+  `        ## %\n" +
160
+                "       \"#'    !!*\"3%$#%!         .!'!'$       \"\"   %.  #   ` !'              +$ 3! !(`           !! $..\n" +
161
+                "       %#'  '(!!!!($##$.         !#% `$'       !+  !(  z  !\".3##$(!          `$! !!.                J!!\"!\n" +
162
+                "       !#\".\"!!!!!!.!!!`           !. .'!!!3.    \"!  %  * .3`  '%####j!!!!!!'` `$! '!(-      !!!`   .#(*!`\n" +
163
+                "        %##`\"' -!!                  \"3!!!\"j.`(`  \"! .         `'\"#############$j#*        .$u!!!!!!j'\n" +
164
+                "         \"#.! .\"!!            '!!    !$'.    !u-  !.      `!I#####################$'      !'\"!!'-!3\"\n" +
165
+                "          \"$'  `.`!        !\"\"\"\"!!!!!!\"       `\"!       `\"##########################3!           \"\"`\n" +
166
+                "           .\"$3\"\"I!       \"!\"\"(! !`!.+!.        '!.    `###############################\"!!.  `!(z!\n" +
167
+                "             .%&.        .! +!!-.(!\"!' !(         \"!   \"####################################%!!.\n" +
168
+                "               '3j!          `'!!`      # !3\"!.        I######################$#$$$%%#########$3!.\n" +
169
+                "                !%!!!!`               .j( z .!$\"       !###################j\"!!-     '\"############\"!!   .+!\n" +
170
+                "      '!\"3$#######%+'.!\"u\"!!'.` ..!!\"\"\"'.!+\"`  !#!      (########################3(.   `!$#############%\"%+(!!!!\n" +
171
+                "   .*$###############$+'\"#J!!!!!!!!.   !(`! !!! .$!      '3#########################$(`   .!&#########!'(. !!!!!\n" +
172
+                " .j######################\"$!!!!!!!!(*'`\"  \"!!``!..#(u!     `(3#########################\"`     '!&###$!!!  \"\"\"\"\"\"\n" +
173
+                "'###########$##############( %#######!'!`!!`    !!.. %!        -!\"$######################!        .! \"\"! !!!!!!.\n" +
174
+                "$########$'  $##############(!#######!!%!        3!!\"\"`(`          '\"#####################t            !$3*!!!'\n" +
175
+                "#########'   .#######################$!          !!    !\"       !!   '$####################\"`!\"j#.      .\"%(\n" +
176
+                "!#$!!'!!+\".   .\"##############    '$!           !(     '$ ' ``'! '+!.  (###################$('!\"!\n" +
177
+                " !$!!!.   !\"!   !$############$.`((           '\"!       # !'.3 !I. -\"I. !####%!!!!%#####$\"!!!!.\n" +
178
+                " !#        `%!   `\"#########$\"!'(`          -\"!  `I    `# .( !( `3!  .j% !!$.!\"!.  `$#\"!!!!\n" +
179
+                " .#!      .#$`  !J#######3!- *.!          !(!    !!    !%  t  \"! `\"\"       '$%!     `\"!\"!\n" +
180
+                "   !*((+\"\"!\". !$######$!    !''        !t\"!      %.    \"!  !!  J'  !%!                '!\n" +
181
+                "            !#####%(!'$`            !j$*.       !*    '$    3  `\".  `\"!\n" +
182
+                "           !\"\"!!!`    !#!`      '!\"J!!!'       !$    `z-    I   `u.   !z'\n" +
183
+                "                       .\"##$$$#%('     \"      !$`    ('     !    `$.   `$!\n" +
184
+                "                             !#`!      !!    !%`                  !#\n" +
185
+                "                           .\"$' '*`    !!   \"*\n" +
186
+                "                         '%%3`         %`  ``\n" +
187
+                "                        .#'!!!!!.    `*!\n" +
188
+                "                          !'!$(``'!\"(!\n" +
189
+                "                             `!$%(!'(u`\n" +
190
+                "                                '!!\"$$!\n");
191
+        /*
192
+
193
+                `!(z$$#####$%+!`                                                   `!!("t"``.
194
+             -*$$j"+!!(!+*"J$###j                                                  !""!!.*""#"!.
195
+           !3"! !!I$3I"!!!'   .!!$.                                             '"(!' .$I(%*!*!#!
196
+         !%!.!$#%(!              '3(             '                            `J"         `''3"!I"
197
+        (+."#3!'!("**!+!!!         !%.           $*                          .#!    !`!!!       .j#.
198
+       .!!#".!!!'                   `$'          !#    !                     ut  '!*!*!("*!    !#!`"`
199
+         $"    .!!!("!!!`      '%##"..$     .!    #.   $                     #(  !!!!!"!!'`    "!`..%
200
+       `$(   !!"!"$&"*"!       3` !##!%      !"   !"   #                     #( $! !!+  `        ## %
201
+       "#'    !!*"3%$#%!         .!'!'$       ""   %.  #   ` !'              +$ 3! !(`           !! $..
202
+       %#'  '(!!!!($##$.         !#% `$'       !+  !(  z  !".3##$(!          `$! !!.                J!!"!
203
+       !#"."!!!!!!.!!!`           !. .'!!!3.    "!  %  * .3`  '%####j!!!!!!'` `$! '!(-      !!!`   .#(*!`
204
+        %##`"' -!!                  "3!!!"j.`(`  "! .         `'"#############$j#*        .$u!!!!!!j'
205
+         "#.! ."!!            '!!    !$'.    !u-  !.      `!I#####################$'      !'"!!'-!3"
206
+          "$'  `.`!        !""""!!!!!!"       `"!       `"##########################3!           ""`
207
+           ."$3""I!       "!""(! !`!.+!.        '!.    `###############################"!!.  `!(z!
208
+             .%&.        .! +!!-.(!"!' !(         "!   "####################################%!!.
209
+               '3j!          `'!!`      # !3"!.        I######################$#$$$%%#########$3!.
210
+                !%!!!!`               .j( z .!$"       !###################j"!!-     '"############"!!   .+!
211
+      '!"3$#######%+'.!"u"!!'.` ..!!"""'.!+"`  !#!      (########################3(.   `!$#############%"%+(!!!!
212
+   .*$###############$+'"#J!!!!!!!!.   !(`! !!! .$!      '3#########################$(`   .!&#########!'(. !!!!!
213
+ .j######################"$!!!!!!!!(*'`"  "!!``!..#(u!     `(3#########################"`     '!&###$!!!  """"""
214
+'###########$##############( %#######!'!`!!`    !!.. %!        -!"$######################!        .! ""! !!!!!!.
215
+$########$'  $##############(!#######!!%!        3!!""`(`          '"#####################t            !$3*!!!'
216
+#########'   .#######################$!          !!    !"       !!   '$####################"`!"j#.      ."%(
217
+!#$!!'!!+".   ."##############    '$!           !(     '$ ' ``'! '+!.  (###################$('!"!
218
+ !$!!!.   !"!   !$############$.`((           '"!       # !'.3 !I. -"I. !####%!!!!%#####$"!!!!.
219
+ !#        `%!   `"#########$"!'(`          -"!  `I    `# .( !( `3!  .j% !!$.!"!.  `$#"!!!!
220
+ .#!      .#$`  !J#######3!- *.!          !(!    !!    !%  t  "! `""       '$%!     `"!"!
221
+   !*((+""!". !$######$!    !''        !t"!      %.    "!  !!  J'  !%!                '!
222
+            !#####%(!'$`            !j$*.       !*    '$    3  `".  `"!
223
+           !""!!!`    !#!`      '!"J!!!'       !$    `z-    I   `u.   !z'
224
+                       ."##$$$#%('     "      !$`    ('     !    `$.   `$!
225
+                             !#`!      !!    !%`                  !#
226
+                           ."$' '*`    !!   "*
227
+                         '%%3`         %`  ``
228
+                        .#'!!!!!.    `*!
229
+                          !'!$(``'!"(!
230
+                             `!$%(!'(u`
231
+                                '!!"$$!
232
+
233
+         */
234
+    }
151 235
 
152 236
 //
153 237
 //    public Integer getPlayersInput(String prompt){

+ 1
- 1
src/main/java/io/zipcoder/casino/utilities/abstracts/Game.java Ver arquivo

@@ -17,6 +17,6 @@ public abstract class Game {
17 17
 
18 18
     protected void announceGameChoice() {
19 19
         Console console = new Console();
20
-        console.println("Welcome to %s\n", this.getClassName());
20
+        console.println("\nWelcome to %s\n", this.getClassName());
21 21
     }
22 22
 }

+ 0
- 3
src/main/java/io/zipcoder/casino/utilities/containers/CardHand.java Ver arquivo

@@ -8,7 +8,6 @@ public class CardHand extends ArrayList<Card> {
8 8
 
9 9
     int numberOfCards = this.size();
10 10
 //    private java.util.ArrayList<Card> cardHand;
11
-//
12 11
 //    public CardHand(int numberOfCards) {
13 12
 //        this.numberOfCards = numberOfCards;
14 13
 //    }
@@ -20,10 +19,8 @@ public class CardHand extends ArrayList<Card> {
20 19
 //    public void addCard(Card card) {
21 20
 //        add(card);
22 21
 //    }
23
-//
24 22
 //    public void removeCard(Card card) {
25 23
 //        remove(card);
26
-//
27 24
 //    }
28 25
 
29 26
     public String display() {

+ 1
- 0
src/main/java/io/zipcoder/casino/utilities/interfaces/Gamble.java Ver arquivo

@@ -3,6 +3,7 @@ package io.zipcoder.casino.utilities.interfaces;
3 3
 import io.zipcoder.casino.player.Player;
4 4
 
5 5
 public interface Gamble {
6
+
6 7
     void placeBet(Player player);
7 8
 
8 9
     void evaluateBet(Player player, long payout);

+ 1
- 0
src/test/java/io/zipcoder/casino/CrapsTest.java Ver arquivo

@@ -17,6 +17,7 @@ public class CrapsTest {
17 17
         CrapsPlayer cplayer2 = new CrapsPlayer(new Player("Joe",100),20);
18 18
         CrapsPlayer cplayer3 = new CrapsPlayer(new Player("Will",100),12);
19 19
 
20
+        //When
20 21
         playerz.add(cplayer1);
21 22
         playerz.add(cplayer2);
22 23
         playerz.add(cplayer3);

+ 123
- 0
src/test/java/io/zipcoder/casino/GoFishTest.java Ver arquivo

@@ -0,0 +1,123 @@
1
+package io.zipcoder.casino;
2
+
3
+import io.zipcoder.casino.player.GoFishPlayer;
4
+import io.zipcoder.casino.player.Player;
5
+import org.junit.Assert;
6
+import org.junit.Test;
7
+
8
+import java.util.ArrayList;
9
+
10
+public class GoFishTest {
11
+
12
+    @Test
13
+    public void goFish() {
14
+        //given
15
+
16
+        //when
17
+
18
+        //then
19
+    }
20
+
21
+    @Test
22
+    public void readyPlayersTest() {
23
+        //given
24
+        ArrayList<GoFishPlayer> fishers = new ArrayList<>();
25
+        GoFishPlayer fisher1 = new GoFishPlayer(new Player("Jae", 0));
26
+        GoFishPlayer fisher2 = new GoFishPlayer(new Player("Thuy", 2));
27
+        GoFishPlayer fisher3 = new GoFishPlayer(new Player("Ned", 0));
28
+        int expectedOutput = 3;
29
+        //when
30
+        fishers.add(fisher1);
31
+        fishers.add(fisher2);
32
+        fishers.add(fisher3);
33
+        //then
34
+        int actualOutput = fishers.size();
35
+        Assert.assertEquals(expectedOutput, actualOutput);
36
+
37
+    }
38
+
39
+    @Test
40
+    public void runGame() {
41
+        //given
42
+
43
+        //when
44
+
45
+        //then
46
+    }
47
+
48
+    @Test
49
+    public void getStartingCardsTest() {
50
+        //given
51
+        ArrayList<GoFishPlayer> fishers = new ArrayList<>();
52
+        GoFishPlayer fisher1 = new GoFishPlayer(new Player("Jae", 0));
53
+        GoFishPlayer fisher2 = new GoFishPlayer(new Player("Thuy", 2));
54
+        GoFishPlayer fisher3 = new GoFishPlayer(new Player("Ned", 0));
55
+        fishers.add(fisher1);
56
+        fishers.add(fisher2);
57
+        fishers.add(fisher3);
58
+        int expectOutput = 7;
59
+        int numberOfPlayers = fishers.size();
60
+
61
+        //when
62
+
63
+
64
+        //then
65
+        int actualOutput = fisher1.getHand().size();
66
+        Assert.assertEquals(expectOutput, actualOutput);
67
+
68
+    }
69
+
70
+    @Test
71
+    public void dealCards() {
72
+        //given
73
+
74
+        //when
75
+
76
+        //then
77
+    }
78
+
79
+    @Test
80
+    public void promptContinue() {
81
+        //given
82
+
83
+        //when
84
+
85
+        //then
86
+    }
87
+
88
+    @Test
89
+    public void playGoFish() {
90
+        //given
91
+
92
+        //when
93
+
94
+        //then
95
+    }
96
+
97
+    @Test
98
+    public void askForOpponent() {
99
+        //given
100
+
101
+        //when
102
+
103
+        //then
104
+    }
105
+
106
+    @Test
107
+    public void searchCard() {
108
+        //given
109
+
110
+        //when
111
+
112
+        //then
113
+    }
114
+
115
+    @Test
116
+    public void checkCards() {
117
+        //given
118
+
119
+        //when
120
+
121
+        //then
122
+    }
123
+}