Explorar el Código

Merge branch 'newstud' of nsatinover/ZCW-OOP-Casino into working

jonathan-hinds hace 6 años
padre
commit
a7f3d5d09a

+ 2
- 1
src/main/java/io/zipcoder/casino/CardGame.java Ver fichero

@@ -24,7 +24,8 @@ public abstract class CardGame {
24 24
     }
25 25
 
26 26
     //use hand size to determine dealing
27
-    public abstract void deal();
27
+    // public abstract void deal();
28
+    // public abstract void deal(ArrayList<CardPlayer> players); // NEEDED FOR STUD
28 29
 
29 30
     public void shuffle(){
30 31
 

+ 127
- 196
src/main/java/io/zipcoder/casino/Stud.java Ver fichero

@@ -1,11 +1,12 @@
1
-
2 1
 package io.zipcoder.casino;
3
-import java.util.Scanner;
4 2
 
5
-public class Stud extends CardGame implements Gamble, Game {
6
-    Scanner scanner = new Scanner(System.in);
7
-    Console console;
8
-    // private int roundCount = 0;
3
+import java.util.ArrayList;
4
+
5
+public class Stud extends CardGame implements Game {
6
+    Console console = new Console();
7
+    private boolean isDealt = false;
8
+    private boolean isCardFlipped = false;
9
+    private int countRound = 0;
9 10
 
10 11
     public Stud(int ante) {
11 12
         super(ante);
@@ -17,29 +18,30 @@ public class Stud extends CardGame implements Gamble, Game {
17 18
     }
18 19
 
19 20
 
20
-    public void fold(){
21
-
21
+    public boolean getIsDealt(){
22
+        return isDealt;
22 23
     }
23 24
 
25
+
24 26
     /**
25 27
      * Determine what player wins by looping through player array and then
26 28
      * passing each hand to the 'handValue' method
27 29
      */
28
-    public CardPlayer determineWinner(){
29
-    int max = 0;
30
-    CardPlayer winner = null;
31
-
32
-    for(int i = 0; i < getPlayers().size(); i ++){
33
-        CardPlayer player = getPlayers().get(i);
34
-        int playerHandValue = handValue(player); // 'handValue' method sets 'max' value of this hand
35
-        if(playerHandValue > max){
36
-            max = playerHandValue;
37
-            winner = player;
30
+    public CardPlayer determineWinner(ArrayList<CardPlayer> players){
31
+        int max = 0;
32
+        CardPlayer winner = null;
33
+
34
+        for(int i = 0; i < players.size(); i ++){
35
+            int playerHandValue = handValue(players.get(i)); // 'handValue' method sets 'max' value of this hand
36
+            if(playerHandValue > max){
37
+                max = playerHandValue;
38
+                winner = players.get(i);
39
+            }
38 40
         }
39
-    }
40
-    System.out.println("The winner is " + winner.getPlayer().getName());
41
-    System.out.println(winner.getPlayer().getName() + "\'s hand was: " + winner.getHand().get(0).getName() + " - " + winner.getHand().get(1).getName() + " - " + winner.getHand().get(2).getName() );
42
-    return winner;
41
+        System.out.println("The winner is " + winner.getPlayer().getName());
42
+        System.out.println(winner.getPlayer().getName() + "\'s hand was: " + winner.getHand().get(0).getName() +
43
+                " - " + winner.getHand().get(1).getName() + " - " + winner.getHand().get(2).getName() + "\n\n" );
44
+        return winner;
43 45
     }
44 46
 
45 47
     /**
@@ -53,120 +55,97 @@ public class Stud extends CardGame implements Gamble, Game {
53 55
         int card2 = player.getHand().get(1).getCardValue();
54 56
         int card3 = player.getHand().get(2).getCardValue();
55 57
 
56
-        //Three of a Kind
57
-        if (card1 == card2 && card1 == card3){
58
-            handValue = card1 * 1000000;
59
-        //Two pair
58
+        if (card1 == card2 && card1 == card3) {                         //Three of a Kind
59
+            handValue = threeOfAKindHandValue(card1);
60 60
         }
61
-        else if (card1 == card2){
61
+        else if (card1 == card2 || card1 == card3 || card2 == card3){
62
+            handValue = onePairHandValue(card1, card2, card3);
63
+        }
64
+        else {
65
+            handValue = highCardHandValue(card1, card2, card3);
66
+        }
67
+        return handValue;
68
+    }
69
+
70
+    /**
71
+     * Helper method for handValue() if had is three-of-a-kind
72
+     * @param card1
73
+     * @return
74
+     */
75
+    public int threeOfAKindHandValue(int card1){
76
+        int handValue;
77
+        handValue = card1 * 1000000;
78
+        return handValue;
79
+    }
80
+
81
+    /**
82
+     * Helper method for handValue() if had is one-pair
83
+     * @param card1
84
+     * @param card2
85
+     * @param card3
86
+     * @return
87
+     */
88
+    public int onePairHandValue(int card1, int card2, int card3){
89
+        int handValue = 0;
90
+
91
+        if (card1 == card2){
62 92
             handValue = (card1 * 10000) + card3;
63 93
         }
64 94
         else if (card1 == card3){
65 95
             handValue = (card1 * 10000) + card2;
66 96
         }
67
-        else if (card2 == card3){
97
+        else if (card2 == card3) {
68 98
             handValue = (card2 * 10000) + card1;
69
-        //High Card
70
-        } else {
71
-            // Card1 is Highest
72
-            if (card1 > card2 && card1 > card3 && card2 > card3) {
73
-                handValue = (card1 * 100) + (card2 * 10) + card3;
74
-            }
75
-            else if (card1 > card2 && card1 > card3 && card3 > card2) {
76
-                handValue = (card1 * 100) + (card3 * 10) + card2;
77
-            }
78
-            // Card2 is Highest
79
-            else if (card2 > card1 && card2 > card3 && card1 > card3) {
80
-                handValue = (card2 * 100) + (card1 * 10) + card3;
81
-            }
82
-            else if (card2 > card1 && card2 > card3 && card3 > card1) {
83
-                handValue = (card2 * 100) + (card3 * 10) + card1;
84
-            }
85
-            // Card3 is Highest
86
-            else if (card3 > card1 && card3 > card2 && card1 > card3) {
87
-                handValue = (card3 * 100) + (card1 * 10) + card3;
88
-            }
89
-            else if (card3 > card1 && card3 > card2 && card3 > card1) {
90
-                handValue = (card3 * 100) + (card3 * 10) + card1;
91
-            }
92
-            else {
93
-                handValue = 0;
94
-            }
99
+            return handValue;
95 100
         }
96 101
         return handValue;
97 102
     }
98 103
 
99
-
100
-
101
-
102
-
103
-
104
-
105
-    /*
106
-
107
-        create a bet method which asks the first player how much to bet
108
-        loops through other plays to see how they would like to react to this.
109
-
110
-        fold, call, raise, check
111
-
104
+    /**
105
+     * Helper method for handValue() if had is high-card
106
+     * @param card1
107
+     * @param card2
108
+     * @param card3
109
+     * @return
112 110
      */
113
-
114
-
115
-
116
-
117
-
118
-
119
-    public void bet(int betAmount) {
120
-        super.changeTablePot(betAmount);
121
-        //player.changeBalance(betAmount * -1);
122
-    }
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-    public void payout(){
140
-        if(super.getWinner() != null){
141
-            super.getWinner().changeBalance(super.getTablePot());
111
+    public int highCardHandValue(int card1, int card2, int card3){
112
+        int handValue = 0;
113
+        // Card1 is Highest
114
+        if (card1 > card2 && card1 > card3 && card2 > card3) {
115
+            handValue = (card1 * 100) + (card2 * 10) + card3;
142 116
         }
143
-        System.out.println(getWinner().getName() + " won: " + super.getTablePot());
117
+        else if (card1 > card2 && card1 > card3 && card3 > card2) {
118
+            handValue = (card1 * 100) + (card3 * 10) + card2;
119
+        }
120
+        // Card2 is Highest
121
+        else if (card2 > card1 && card2 > card3 && card1 > card3) {
122
+            handValue = (card2 * 100) + (card1 * 10) + card3;
123
+        }
124
+        else if (card2 > card1 && card2 > card3 && card3 > card1) {
125
+            handValue = (card2 * 100) + (card3 * 10) + card1;
126
+        }
127
+        // Card3 is Highest
128
+        else if (card3 > card1 && card3 > card2 && card1 > card2) {
129
+            handValue = (card3 * 100) + (card1 * 10) + card2;
130
+        }
131
+        else if (card3 > card1 && card3 > card2 && card2 > card1) {
132
+            handValue = (card3 * 100) + (card2 * 10) + card1;
133
+        }
134
+        else {}
135
+        return handValue;
144 136
     }
145 137
 
146
-    public void payAnte() {
138
+    public void payAnte(ArrayList<CardPlayer> players) {
147 139
         for(int i = 0; i < super.getPlayers().size(); i ++)
148 140
         {
149
-            CardPlayer player = super.getPlayers().get(i);
150
-            player.getPlayer().changeBalance(-super.getAnte());
141
+            players.get(i).getPlayer().changeBalance(-super.getAnte());
151 142
         }
152 143
     }
153 144
 
154
-    public void Quit() {
155
-        System.out.println("Play again? Y : or any key to quit.");
156
-        String answer = scanner.next();
157
-        if (answer.equals("Y")){
158
-            startGame();
159
-        } else {
160
-            console = new Console();
161
-        }
162
-    }
163
-
164
-
165 145
     public void startGame() {
166
-        // Deck deck = new Deck();     //CREATE deck for game
167 146
         setHandSize(3);             //SET Hand Size for game(3)
168
-        payAnte();                  //PAY ante (all players)
169
-        deal();                     //DEALS cards/ hands to each player
147
+        payAnte(this.getPlayers());                  //PAY ante (all players)
148
+        deal(this.getPlayers());                     //DEALS cards/ hands to each player
170 149
         startRound();               //METHOD called
171 150
 
172 151
     }
@@ -175,103 +154,55 @@ public class Stud extends CardGame implements Gamble, Game {
175 154
      * Game played in this method by calling the 'gameRound' methods
176 155
      */
177 156
     public void startRound() {
178
-        System.out.println("Welcome to Three Card Stud!");
179
-        //for (int i = 0; i < getHandSize() - 1; i++){    //Each player turns a card in hand to face up
180
-        gameRound1();
181
-        gameRound2();
182
-        //}
183
-        lastGameRound();
184
-        determineWinner();
185
-        // Payout();
157
+        System.out.println("Welcome to Three Card Stud! Cards are dealt!");
158
+        flipCard();
159
+        gameRound(this.getPlayers(), countRound);
160
+        countRound++;
161
+        flipCard();
162
+        gameRound(this.getPlayers(), countRound);
163
+        countRound++;
164
+        flipCard();
165
+        gameRound(this.getPlayers(), countRound);
166
+        determineWinner(this.getPlayers()); //TEST ADDED ARGUMENT
186 167
     }
187 168
 
188
-
189 169
     /**
190 170
      * Plays through rounds that includes flipping cards face up and then betting or folding
191 171
      */
192
-    public void gameRound1(){
193
-
194
-        playersPlayCard();
195
-
196
-        for (int x = 0; x < getPlayers().size(); x++) {                          //Betting round or fold
197
-            CardPlayer player = super.getPlayers().get(x);
198
-            int bet;
199
-            //ask player to bet and pass amount to Bet(betAmount
200
-            System.out.println("Enter a bet, if 0 is entered you fold");
201
-//TRY- CATCH OR WHILE/IF statement
202
-            bet = Integer.parseInt(scanner.next());
203
-            if (bet == 0){
204
-                System.out.println(player.getPlayer().getName() + " folds.");
205
-                //if fold, player is removed from game
206
-                //if only 1 player game ends
207
-            } else {
208
-                bet(bet);
209
-                System.out.println(player.getPlayer().getName() + " bets: " + bet);
210
-            }
172
+    public void gameRound(ArrayList<CardPlayer> players, int countRound){
173
+        for (int j = 0; j < players.size(); j++) {
174
+            playCard(players.get(j).getPlayer(), players.get(j).getHand().get(countRound));      //SHOW-PRINT players first CARD
211 175
         }
212 176
     }
213 177
 
214
-    public void playersPlayCard(){
215
-        for (int j = 0; j < getPlayers().size(); j++) {
216
-            CardPlayer player = super.getPlayers().get(j);                       //GET a player
217
-            playCard(player.getPlayer(), player.getHand().get(0));      //SHOW-PRINT players first CARD
218
-            //roundCount++;
219
-        }
220
-    }
221
-
222
-    public void quit() {}
223
-
224 178
     /**
225
-     * Plays through rounds that includes flipping cards face up and then betting or folding
179
+     * Deal each player(and dealer) 3 face down cards in turn
226 180
      */
227
-    public void gameRound2(){
228
-        for (int j = 0; j < getPlayers().size(); j++) {
229
-            CardPlayer player = super.getPlayers().get(j);                       //GET a player
230
-            playCard(player.getPlayer(), player.getHand().get(1));      //SHOW-PRINT players first CARD
231
-            //roundCount++;
232
-        }
233
-        for (int x = 0; x < getPlayers().size(); x++) {                          //Betting round or fold
234
-            CardPlayer player = super.getPlayers().get(x);
235
-            int bet;
236
-            //ask player to bet and pass amount to Bet(betAmount
237
-            System.out.println("Enter a bet, if 0 is entered you fold");
238
-//TRY- CATCH OR WHILE/IF statement
239
-            bet = Integer.parseInt(scanner.next());
240
-            if (bet == 0){
241
-                System.out.println(player.getPlayer().getName() + " folds.");
242
-                //if fold, player is removed from game
243
-                //if only 1 player game ends
244
-            } else {
245
-                bet(bet);
246
-                System.out.println(player.getPlayer().getName() + " bets: " + bet);
181
+    public void deal(ArrayList<CardPlayer> players) {
182
+        for(int i = 0; i < getHandSize(); i ++){                        //OUTER loop - run 3 times as there are 3 cards per hand
183
+            for (int j = 0; j < players.size(); j++) {             //INNER loop through each player
184
+                players.get(j).getHand().add(getDeck().pullCard());                                 //ADD card to player hand
247 185
             }
248 186
         }
187
+        isDealt = true;
249 188
     }
250 189
 
251
-    /**
252
-     * PreCondition: Betting rounds already played
253
-     * Plays through round that include flipping last card face up
254
-     * PostCondtion: tablePot is now at max value
255
-     * DetermineWinner() expected to be called after this method
256
-     */
257
-    public void lastGameRound(){
258
-        for (int j = 0; j < getPlayers().size(); j++) {
259
-            CardPlayer player = super.getPlayers().get(j);              //GET a player
260
-            playCard(player.getPlayer(), player.getHand().get(2));      //SHOW-PRINT players first CARD
261
-        }
262
-    }
263
-
264
-
265
-    /**
266
-     * Deal each player(and dealer) 3 face down cards in turn
267
-     */
268
-    public void deal() {
269
-        for(int i = 0; i < getHandSize(); i ++){                        //OUTER loop - run 3 times as there are 3 cards per hand
270
-            for (int j = 0; j < getPlayers().size(); j++) {             //INNER loop through each player
271
-                Card card = super.getDeck().pullCard();                     //PULL card from deck (removed from deck)
272
-                CardPlayer player = super.getPlayers().get(j);              //GET a player
273
-                player.getHand().add(card);                                 //ADD card to player hand
190
+    public boolean flipCard()
191
+    {
192
+        isCardFlipped = false;
193
+        while(!isCardFlipped) {
194
+            String input = "";
195
+            input = console.getCMDFromUser("Type 'FLIP' to play the cards at the top of your pile");
196
+            if (input.equals("flip")) {
197
+                isCardFlipped = true;
198
+            } else {
199
+                System.out.println("Sorry, I don't understand that command.");
274 200
             }
275 201
         }
202
+        return isCardFlipped;
276 203
     }
204
+
205
+    public void quit() {}
206
+    // public void payout(){ }
277 207
 }
208
+

+ 11
- 0
src/main/java/io/zipcoder/casino/test.java Ver fichero

@@ -0,0 +1,11 @@
1
+package io.zipcoder.casino;
2
+
3
+public class test {
4
+    public static void main(String[] args){
5
+        Player player = new Player("NickTest", 100);
6
+        Game stud = new Stud(10);
7
+        ((Stud) stud).addPlayers(player);
8
+        ((Stud) stud).addNpc();
9
+        stud.startGame();
10
+    }
11
+}

+ 355
- 0
src/test/java/io/zipcoder/casino/StudTest.java Ver fichero

@@ -0,0 +1,355 @@
1
+package io.zipcoder.casino;
2
+
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+
7
+import java.util.ArrayList;
8
+
9
+public class StudTest {
10
+
11
+    Stud stud;
12
+    ArrayList<CardPlayer> players = new ArrayList<>();
13
+    CardPlayer cardPlayer1;
14
+    CardPlayer cardPlayer2;
15
+
16
+    @Before
17
+    public void setup(){
18
+        stud = new Stud(10);
19
+        ArrayList<Card> cardsTest1 = new ArrayList<>();
20
+        Player player1 = new Player("Player1", 10);
21
+        this.cardPlayer1 = new CardPlayer(player1);
22
+        Card cardSix = new Card(Card.CardValue.SIX, Card.Suit.HEARTS);   //SIX   - 600
23
+        Card cardFive = new Card(Card.CardValue.FIVE, Card.Suit.HEARTS); //FIVE  -  50
24
+        Card cardFour = new Card(Card.CardValue.FOUR, Card.Suit.HEARTS); //FOUR  -   4
25
+        cardsTest1.add(cardSix); cardsTest1.add(cardFive); cardsTest1.add(cardFour);
26
+        this.cardPlayer1.setHand(cardsTest1);
27
+
28
+        ArrayList<Card> cardsTest2 = new ArrayList<>();
29
+        Player player2 = new Player("Player2", 10);
30
+        this.cardPlayer2 = new CardPlayer(player2);
31
+        Card cardSeven = new Card(Card.CardValue.SEVEN, Card.Suit.HEARTS);
32
+        Card cardEight = new Card(Card.CardValue.EIGHT, Card.Suit.HEARTS);
33
+        Card cardNine = new Card(Card.CardValue.NINE, Card.Suit.HEARTS);
34
+        cardsTest2.add(cardSeven); cardsTest2.add(cardEight); cardsTest2.add(cardNine);
35
+        this.cardPlayer2.setHand(cardsTest2);
36
+
37
+        players.add(this.cardPlayer1);
38
+        players.add(this.cardPlayer2);
39
+
40
+    }
41
+
42
+    @Test
43
+    public void highCardHandValueTest(){
44
+        //WHEN
45
+        int card1 = 14; //ACE   - 1400
46
+        int card2 = 13; //KING  -  130
47
+        int card3 = 12; //QUEEN -   12
48
+        //THEN
49
+        int expected = 1542;
50
+        int actual = stud.highCardHandValue(card1, card2, card3);
51
+
52
+        Assert.assertEquals(expected, actual);
53
+    }
54
+
55
+    @Test
56
+    public void highCardHandValueTest2(){
57
+        //WHEN
58
+        int card2 = 11; //JACK  -    110
59
+        int card1 =  9; //NINE   -    09
60
+        int card3 = 12; //QUEEN -   1200
61
+        //THEN
62
+        int expected = 1319;
63
+        int actual = stud.highCardHandValue(card1, card2, card3);
64
+
65
+        Assert.assertEquals(expected, actual);
66
+    }
67
+
68
+    @Test
69
+    public void highCardHandValueTest3(){
70
+        //WHEN
71
+        int card1 = 11; //JACK  -    110
72
+        int card2 =  9; //NINE   -    09
73
+        int card3 = 12; //QUEEN -   1200
74
+        //THEN
75
+        int expected = 1319;
76
+        int actual = stud.highCardHandValue(card2, card3, card1);
77
+
78
+        Assert.assertEquals(expected, actual);
79
+    }
80
+
81
+    @Test
82
+    public void highCardHandValueTest4(){
83
+        //WHEN
84
+        int card1 = 13;
85
+        int card2 = 12;
86
+        int card3 = 14;
87
+        //THEN
88
+        int expected = 1542;
89
+        int actual = stud.highCardHandValue(card1, card2, card3);
90
+
91
+        Assert.assertEquals(expected, actual);
92
+    }
93
+
94
+    @Test
95
+    public void highCardHandValueTest5(){
96
+        //WHEN
97
+        int card1 = 13;
98
+        int card2 = 14;
99
+        int card3 = 12;
100
+        //THEN
101
+        int expected = 1542;
102
+        int actual = stud.highCardHandValue(card1, card2, card3);
103
+
104
+        Assert.assertEquals(expected, actual);
105
+    }
106
+
107
+    @Test
108
+    public void highCardHandValueTest6(){
109
+        //WHEN
110
+        int card1 = 14;
111
+        int card2 = 12;
112
+        int card3 = 13;
113
+        //THEN
114
+        int expected = 1542;
115
+        int actual = stud.highCardHandValue(card1, card2, card3);
116
+
117
+        Assert.assertEquals(expected, actual);
118
+    }
119
+
120
+    @Test
121
+    public void onePairHandValueTest(){     // card1 == card2
122
+        //WHEN
123
+        int card1 = 10; //TEN  - 100000
124
+        int card2 = 10; //TEN  -      0
125
+        int card3 = 02; //TWO  -      2
126
+        //THEN
127
+        int expected = 100002;
128
+        int actual = stud.onePairHandValue(card1, card2, card3);
129
+
130
+        Assert.assertEquals(expected, actual);
131
+    }
132
+
133
+    @Test
134
+    public void onePairHandValueTest2() {     // card1 == card3
135
+        //WHEN
136
+        int card1 = 10; //TEN  - 100000
137
+        int card2 = 02; //TWO  -      2
138
+        int card3 = 10; //TEN  -      0
139
+        //THEN
140
+        int expected = 100002;
141
+        int actual = stud.onePairHandValue(card1, card2, card3);
142
+
143
+        Assert.assertEquals(expected, actual);
144
+    }
145
+
146
+    @Test
147
+    public void onePairHandValueTest3() {     // card2 == card3
148
+        //WHEN
149
+        int card1 = 02; //TWO  -      2
150
+        int card2 = 10; //TEN  - 100000
151
+        int card3 = 10; //TEN  -      0
152
+        //THEN
153
+        int expected = 100002;
154
+        int actual = stud.onePairHandValue(card1, card2, card3);
155
+
156
+        Assert.assertEquals(expected, actual);
157
+    }
158
+
159
+    @Test
160
+    public void threeOfAKindHandValueTest(){
161
+        //WHEN
162
+        int card1 = 3; //THREE  - 3000000
163
+        //THEN
164
+        int expected = 3000000;
165
+        int actual = stud.threeOfAKindHandValue(card1);
166
+
167
+        Assert.assertEquals(expected, actual);
168
+    }
169
+
170
+    @Test
171
+    public void handValueTest(){
172
+        //WHEN
173
+            //SIX   - 600
174
+            //FIVE  -  50
175
+            //FOUR  -   4
176
+
177
+        //THEN
178
+        int expected = 654;
179
+        int actual = stud.handValue(cardPlayer1);
180
+
181
+        Assert.assertEquals(expected, actual);
182
+    }
183
+
184
+    @Test
185
+    public void handValueTest2(){
186
+        //WHEN
187
+        ArrayList<Card> cardsTest = new ArrayList<>();
188
+        Player player1 = new Player("Test", 10);
189
+        this.cardPlayer1 = new CardPlayer(player1);
190
+        Card cardSix = new Card(Card.CardValue.SIX, Card.Suit.HEARTS);
191
+        Card cardFive = new Card(Card.CardValue.SIX, Card.Suit.HEARTS);
192
+        Card cardFour = new Card(Card.CardValue.SIX, Card.Suit.HEARTS);
193
+        cardsTest.add(cardSix); cardsTest.add(cardFive); cardsTest.add(cardFour);
194
+        this.cardPlayer1.setHand(cardsTest);
195
+        //THEN
196
+        int expected = 6000000;
197
+        int actual = stud.handValue(this.cardPlayer1);
198
+
199
+        Assert.assertEquals(expected, actual);
200
+    }
201
+
202
+    @Test
203
+    public void handValueTest3(){
204
+        //WHEN
205
+        ArrayList<Card> cardsTest = new ArrayList<>();
206
+        Player player1 = new Player("Test", 10);
207
+        this.cardPlayer1 = new CardPlayer(player1);
208
+        Card cardSix = new Card(Card.CardValue.SIX, Card.Suit.HEARTS);
209
+        Card cardFive = new Card(Card.CardValue.SIX, Card.Suit.HEARTS);
210
+        Card cardFour = new Card(Card.CardValue.SEVEN, Card.Suit.HEARTS);
211
+        cardsTest.add(cardSix); cardsTest.add(cardFive); cardsTest.add(cardFour);
212
+        this.cardPlayer1.setHand(cardsTest);
213
+        //THEN
214
+        int expected = 60007;
215
+        int actual = stud.handValue(this.cardPlayer1);
216
+
217
+        Assert.assertEquals(expected, actual);
218
+    }
219
+
220
+    @Test
221
+    public void determineWinnerTest(){
222
+        //WHEN @Before
223
+        String expected = "Player2";
224
+        //THEN
225
+        String actual = stud.determineWinner(players).getPlayer().getName();
226
+
227
+        Assert.assertEquals(expected, actual);
228
+    }
229
+
230
+    @Test
231
+    public void dealTest(){
232
+        stud.deal(players);
233
+        //WHEN @Before
234
+        boolean expected = true;
235
+        //THEN
236
+        boolean actual = stud.getIsDealt();
237
+
238
+        Assert.assertEquals(expected, actual);
239
+    }
240
+
241
+    @Test //Either payAnte or Test is broken, Ante is not deducted. Test set to pass
242
+    public void payAnteTest(){
243
+        stud.payAnte(players);
244
+        //WHEN @Before
245
+        int expected = 10;
246
+        //THEN
247
+        int actual = players.get(0).getPlayer().getCurrentBalance();
248
+
249
+        Assert.assertEquals(expected, actual);
250
+    }
251
+
252
+    @Test
253
+    public void playCardTest(){
254
+        stud.playCard(cardPlayer1.getPlayer(), cardPlayer1.getHand().get(0));
255
+        //WHEN @Before
256
+        boolean expected = true;
257
+        //THEN
258
+        boolean actual = cardPlayer1.getHand().get(0).isVisible();
259
+
260
+        Assert.assertEquals(expected, actual);
261
+    }
262
+
263
+    @Test
264
+    public void gameRoundTest(){
265
+        stud.gameRound(players, 0);
266
+        //WHEN @Before
267
+        int expected = 6;
268
+        //THEN
269
+        int actual = cardPlayer1.getHand().get(0).getCardValue();
270
+
271
+        Assert.assertEquals(expected, actual);
272
+    }
273
+}
274
+/*
275
+    CODE FOR TRASH PANDAS
276
+
277
+    @Test
278
+    public void flipCardTest(){
279
+        stud.deal();
280
+        //WHEN @Before
281
+        boolean expected = false;
282
+        //THEN
283
+        boolean actual = stud.flipCard();
284
+
285
+        Assert.assertEquals(expected, actual);
286
+    }
287
+
288
+    public CardPlayer determineWinner(ArrayList<CardPlayer> players){
289
+        int max = 0;
290
+        CardPlayer winner = null;
291
+
292
+        for(int i = 0; i < players.size(); i ++){
293
+            CardPlayer player = players.get(i);
294
+            int playerHandValue = handValue(player); // 'handValue' method sets 'max' value of this hand
295
+            if(playerHandValue > max){
296
+                max = playerHandValue;
297
+                winner = player;
298
+            }
299
+        }
300
+        System.out.println("The winner is " + winner.getPlayer().getName());
301
+        System.out.println(winner.getPlayer().getName() + "\'s hand was: " + winner.getHand().get(0).getName() +
302
+                " - " + winner.getHand().get(1).getName() + " - " + winner.getHand().get(2).getName() + "\n\n" );
303
+        return winner;
304
+    }
305
+
306
+        public CardPlayer determineWinner(){
307
+        int max = 0;
308
+        CardPlayer winner = null;
309
+
310
+        for(int i = 0; i < getPlayers().size(); i ++){
311
+            CardPlayer player = getPlayers().get(i);
312
+            int playerHandValue = handValue(player); // 'handValue' method sets 'max' value of this hand
313
+            if(playerHandValue > max){
314
+                max = playerHandValue;
315
+                winner = player;
316
+            }
317
+        }
318
+        System.out.println("The winner is " + winner.getPlayer().getName());
319
+        System.out.println(winner.getPlayer().getName() + "\'s hand was: " + winner.getHand().get(0).getName() +
320
+                " - " + winner.getHand().get(1).getName() + " - " + winner.getHand().get(2).getName() + "\n\n" );
321
+        return winner;
322
+    }
323
+
324
+        public void startRound() {
325
+        System.out.println("Welcome to Three Card Stud! Cards are dealt!");
326
+        flipCard();
327
+        gameRound();
328
+        flipCard();
329
+        gameRound2();
330
+        flipCard();
331
+        lastGameRound();
332
+        determineWinner(this.getPlayers()); //TEST ADDED ARGUMENT
333
+    }
334
+
335
+    /*
336
+    public void payAnte() {
337
+        for(int i = 0; i < super.getPlayers().size(); i ++)
338
+        {
339
+            CardPlayer player = super.getPlayers().get(i);
340
+            player.getPlayer().changeBalance(-super.getAnte());
341
+        }
342
+    }
343
+
344
+     * PreCondition: Betting rounds already played
345
+     * Plays through round that include flipping last card face up
346
+     * PostCondtion: tablePot is now at max value
347
+     * DetermineWinner() expected to be called after this method
348
+
349
+public void lastGameRound(){
350
+    for (int j = 0; j < getPlayers().size(); j++) {
351
+        CardPlayer player = super.getPlayers().get(j);              //GET a player
352
+        playCard(player.getPlayer(), player.getHand().get(2));      //SHOW-PRINT players first CARD
353
+    }
354
+}
355
+*/