Simran Bhutani 6 anos atrás
pai
commit
bb0be794ba

+ 2
- 25
src/main/java/io/zipcoder/casino/Card.java Ver arquivo

@@ -14,22 +14,15 @@ public class Card {
14 14
         this.name = cardValue + " of " + suit;
15 15
     }
16 16
 
17
+
17 18
     public String getName() {
18 19
         return name;
19 20
     }
20 21
 
21
-    public void setName(String name) {
22
-        this.name = name;
23
-    }
24
-
25 22
     public boolean isVisible() {
26 23
         return isVisible;
27 24
     }
28 25
 
29
-    public void setVisible(boolean visible) {
30
-        isVisible = visible;
31
-    }
32
-
33 26
     public void setVisibility(boolean visibility){
34 27
         isVisible = visibility;
35 28
     }
@@ -39,21 +32,11 @@ public class Card {
39 32
         return suit;
40 33
     }
41 34
 
42
-    public void setSuit(Suit suit)
43
-    {
44
-        this.suit = suit;
45
-    }
46
-
47 35
     public int getCardValue()
48 36
     {
49 37
         return cardValue.getCardValue();
50 38
     }
51 39
 
52
-    public void setCardValue(CardValue cardValue)
53
-    {
54
-        this.cardValue = cardValue;
55
-    }
56
-
57 40
     public enum CardValue
58 41
     {
59 42
         TWO(2),
@@ -94,11 +77,5 @@ public class Card {
94 77
         Suit (String suitValue)
95 78
         {
96 79
             this.suitValue = suitValue;
97
-        }
98
-
99
-        public String getSuitValue(){
100
-            return suitValue;
101
-        }
102
-
103
-    }
80
+        }}
104 81
 }

+ 1
- 14
src/main/java/io/zipcoder/casino/CardGame.java Ver arquivo

@@ -8,8 +8,6 @@ import java.util.HashMap;
8 8
 public abstract class CardGame {
9 9
 
10 10
     private int tablePot;
11
-    private int minBet;
12
-    private int maxBet;
13 11
     private int handSize;
14 12
     private int ante;
15 13
     private CardPlayer playersTurn;
@@ -23,16 +21,6 @@ public abstract class CardGame {
23 21
         this.ante = ante;
24 22
     }
25 23
 
26
-    //use hand size to determine dealing
27
-    // public abstract void deal();
28
-    // public abstract void deal(ArrayList<CardPlayer> players); // NEEDED FOR STUD
29
-
30
-    public void shuffle(){
31
-
32
-        //shuffle the card stack
33
-
34
-    }
35
-
36 24
     public Deck getDeck() {
37 25
         return deck;
38 26
     }
@@ -48,7 +36,6 @@ public abstract class CardGame {
48 36
         }
49 37
     }
50 38
 
51
-
52 39
     public int getAnte(){
53 40
         return ante;
54 41
     }
@@ -85,7 +72,7 @@ public abstract class CardGame {
85 72
         addPlayers(new NPC("Opponant", getAnte()));
86 73
     }
87 74
 
88
-    public void chooseStatingPlayer(){
75
+    public void chooseStartingPlayer(){
89 76
         //loop through the players
90 77
         for(int i = 0; i < getPlayers().size(); i ++){
91 78
             //if one is not an NPC

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

@@ -71,7 +71,7 @@ public class Casino {
71 71
                         Printer.printMessage("Invalid bet amount entered, min bet for slot is $1 and max $100 ");
72 72
                         break;
73 73
                     }
74
-                    Game slot= new SlotMachine(slotBet1);
74
+                    Game slot= new SlotMachine(slotBet1, player);
75 75
                     game = slot;
76 76
                     slot.startGame();
77 77
                     ((SlotMachine) slot).slotResult();

+ 39
- 15
src/main/java/io/zipcoder/casino/SlotMachine.java Ver arquivo

@@ -12,19 +12,26 @@ public class SlotMachine implements Game, Gamble {
12 12
     String word2="";
13 13
     String word3="";
14 14
     double totalBet=0;
15
+    Player player;
16
+
17
+    public SlotMachine(int betAmount, Player player) {
15 18
 
16
-    public SlotMachine(int betAmount) {
17 19
         this.betAmount = betAmount;
20
+        this.player = player;
18 21
     }
19 22
 
20 23
     @Override
21 24
     public void bet(int betAmount) {
22 25
 
23 26
         this.betAmount= betAmount;
27
+        player.changeBalance(-betAmount);
28
+
24 29
     }
25 30
 
26 31
     public void payout(){
32
+        getPlayer().changeBalance(payoutAmt);
27 33
         Printer.printMessage("Your payout amount for slot machine is: $" + payoutAmt + "\n");
34
+
28 35
     }
29 36
 
30 37
     @Override
@@ -37,15 +44,10 @@ public class SlotMachine implements Game, Gamble {
37 44
         }
38 45
         Printer.printMessage("Your slot is in progress" + "\n");
39 46
 
40
-        try {
41
-            Thread.sleep(3000);
42
-        } catch (InterruptedException e) {
43
-            e.printStackTrace();
44
-        }
45
-
46
-
47
-        outputword = "";
47
+        startRound();
48
+    }
48 49
 
50
+    public void generateWords() {
49 51
         Random rand = new Random();
50 52
 
51 53
         generateWords(rand);
@@ -85,27 +87,28 @@ public class SlotMachine implements Game, Gamble {
85 87
                 word3 = word;
86 88
             }
87 89
         }
90
+
91
+        outputword= "[ " + word1+ " ]" + "   " + "[ " + word2 + " ]" + "   "+ "[ " + word3 + " ]" + "\n" ;
92
+
88 93
     }
89 94
 
90 95
     public void slotResult()
91 96
     {
92
-            outputword= "[ " + word1+ " ]" + "   " + "[ " + word2 + " ]" + "   "+ "[ " + word3 + " ]" + "\n" ;
93
-
94 97
             if(((!word1.equals(word2)) )&& ((!word1.equals(word3))) && ((!word2.equals(word3)))){
95 98
 
96 99
                 outputword= outputword + "\n"+" You have won $0";
97
-                payoutAmt=0;
100
+                setPayoutAmt(0);
98 101
             }
99 102
             else if( (word1.equals(word2) && (!word1.equals(word3))) || ((word1.equals(word3)) && (!word1.equals(word2))) || ((word2.equals(word3)) && (!word2.equals(word1)))){
100 103
 
101 104
                 outputword= outputword + "\n" +" You have won $" + (betAmount*2);
102
-                payoutAmt=betAmount*2;
105
+                setPayoutAmt(betAmount*2);
103 106
             }
104 107
 
105 108
 
106
-            else if(word1.equals(word2) && word1.equals(word3)  /*&& ((word2.equals(word1)) && (word2.equals(word3))) && ( (word3.equals(word1)) && (word3.equals(word2)))*/){
109
+            else if(word1.equals(word2) && word1.equals(word3)) {
107 110
                 outputword= outputword + "\n" + "You have won $" + (betAmount*3);
108
-                payoutAmt=betAmount*3;
111
+                setPayoutAmt(betAmount*3);
109 112
             }
110 113
 
111 114
             Printer.printMessage(( outputword + "\n" ));
@@ -119,12 +122,24 @@ public class SlotMachine implements Game, Gamble {
119 122
 
120 123
     @Override
121 124
     public void startRound() {
125
+        try {
126
+            Thread.sleep(3000);
127
+        } catch (InterruptedException e) {
128
+            e.printStackTrace();
129
+        }
122 130
 
131
+        generateWords();
123 132
     }
133
+
124 134
     public int getPayoutAmt() {
125 135
 
126 136
         return payoutAmt;
127 137
     }
138
+
139
+    public void setPayoutAmt(int payoutAmt) {
140
+        this.payoutAmt = payoutAmt;
141
+    }
142
+
128 143
     public void setWord1(String word1) {
129 144
 
130 145
         this.word1 = word1;
@@ -137,5 +152,14 @@ public class SlotMachine implements Game, Gamble {
137 152
     public void setWord3(String word3) {
138 153
         this.word3 = word3;
139 154
     }
155
+
156
+    public String getOutputword() {
157
+        return outputword;
158
+    }
159
+
160
+    public Player getPlayer() {
161
+        return player;
162
+    }
163
+
140 164
 }
141 165
 

+ 14
- 12
src/main/java/io/zipcoder/casino/Stud.java Ver arquivo

@@ -1,6 +1,7 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 import java.util.ArrayList;
4
+import java.util.Scanner;
4 5
 
5 6
 public class Stud extends CardGame implements Game {
6 7
     Console console = new Console();
@@ -17,12 +18,10 @@ public class Stud extends CardGame implements Game {
17 18
         Printer.printMessage(player.getName() + " shows a " + card.getName());         //PRINT card name to CONSOLE
18 19
     }
19 20
 
20
-
21 21
     public boolean getIsDealt(){
22 22
         return isDealt;
23 23
     }
24 24
 
25
-
26 25
     /**
27 26
      * Determine what player wins by looping through player array and then
28 27
      * passing each hand to the 'handValue' method
@@ -138,15 +137,17 @@ public class Stud extends CardGame implements Game {
138 137
     public void payAnte(ArrayList<CardPlayer> players) {
139 138
         for(int i = 0; i < super.getPlayers().size(); i ++)
140 139
         {
141
-            players.get(i).getPlayer().changeBalance(-super.getAnte());
140
+            //players.get(i).getPlayer().changeBalance(-super.getAnte());
141
+            CardPlayer player = super.getPlayers().get(i);
142
+            player.getPlayer().changeBalance(-super.getAnte());
142 143
         }
143 144
     }
144 145
 
145 146
     public void startGame() {
146
-        setHandSize(3);             //SET Hand Size for game(3)
147
-        payAnte(this.getPlayers());                  //PAY ante (all players)
148
-        deal(this.getPlayers());                     //DEALS cards/ hands to each player
149
-        startRound();               //METHOD called
147
+        setHandSize(3);                 //SET Hand Size for game(3)
148
+        payAnte(this.getPlayers());     //PAY ante (all players)
149
+        deal(this.getPlayers());        //DEALS cards/ hands to each player
150
+        startRound();                   //METHOD called
150 151
 
151 152
     }
152 153
 
@@ -179,9 +180,9 @@ public class Stud extends CardGame implements Game {
179 180
      * Deal each player(and dealer) 3 face down cards in turn
180 181
      */
181 182
     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
183
+        for(int i = 0; i < getHandSize(); i ++){
184
+            for (int j = 0; j < players.size(); j++) {
185
+                players.get(j).getHand().add(getDeck().pullCard());
185 186
             }
186 187
         }
187 188
         isDealt = true;
@@ -202,7 +203,8 @@ public class Stud extends CardGame implements Game {
202 203
         return isCardFlipped;
203 204
     }
204 205
 
205
-    public void quit() {}
206
-    // public void payout(){ }
206
+    public void setScanner(Scanner scanner){
207
+        this.console.setScanner(scanner);
208
+    }
207 209
 }
208 210
 

+ 12
- 9
src/main/java/io/zipcoder/casino/War.java Ver arquivo

@@ -1,11 +1,6 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 import java.util.*;
4
-import java.util.concurrent.Executors;
5
-import java.util.concurrent.ScheduledExecutorService;
6
-import java.util.concurrent.TimeUnit;
7
-import java.util.regex.Pattern;
8
-import java.util.concurrent.TimeUnit;
9 4
 
10 5
 public class War extends CardGame implements Gamble, Game {
11 6
 
@@ -114,14 +109,17 @@ public class War extends CardGame implements Gamble, Game {
114 109
         }
115 110
     }
116 111
 
112
+
117 113
     public void startGame(){
118 114
         Printer.printMessage("Welcome to War!");
119
-        super.chooseStatingPlayer();
115
+        super.chooseStartingPlayer();
120 116
         payAnte();
121 117
         deal();
122 118
         startRound();
123 119
     }
124 120
 
121
+
122
+
125 123
     public void startRound() {
126 124
         while(super.getLoser() == null) {
127 125
             String input = console.getCMDFromUser("Type 'FLIP' to play the card at the top of your pile");
@@ -131,9 +129,6 @@ public class War extends CardGame implements Gamble, Game {
131 129
                 Printer.printMessage(winner.getPlayer().getName() + " has been rewarded " + tableCards.size() + " cards.");
132 130
                 winner.addDiscard(tableCards);
133 131
                 tableCards = new ArrayList<Card>();
134
-            }else if(input.equals("quit")){
135
-                Printer.printMessage("Thanks for playing chump!");
136
-                console.getScanner().close();
137 132
             } else {
138 133
                 Printer.printMessage("Sorry, I don't understand that command.");
139 134
             }
@@ -159,4 +154,12 @@ public class War extends CardGame implements Gamble, Game {
159 154
         }
160 155
         Printer.printMessage(super.getPlayersTurn().getPlayer().getName() + "has: " + super.getPlayersTurn().getHand().size() + " cards.");
161 156
     }
157
+
158
+    public void setScanner(Scanner scanner) {
159
+        this.console.setScanner(scanner);
160
+    }
161
+
162
+    public ArrayList<CardPlayer> getWarMembers() {
163
+        return warMembers;
164
+    }
162 165
 }

+ 2
- 2
src/main/java/io/zipcoder/casino/Yahtzee.java Ver arquivo

@@ -1,7 +1,6 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 import java.util.ArrayList;
4
-import java.util.Scanner;
5 4
 
6 5
 public class Yahtzee extends DiceGame implements Game, Gamble {
7 6
 
@@ -46,7 +45,8 @@ public class Yahtzee extends DiceGame implements Game, Gamble {
46 45
                 int rollChoice = console.getIntFromUser("Would you like to:\n1. Roll all dice again.\n2. Roll some dice again.\n3. Stop rolling and score.\nNumber of Selection: ");
47 46
                 String diceToRoll = "";
48 47
                 if(rollChoice == 2) {
49
-                    diceToRoll = console.getLineFromUser("Which numbers would you like to reroll? List the numbers separated by spaces.");
48
+                    Console console2 = new Console();
49
+                    diceToRoll = console2.getLineFromUser("Which numbers would you like to reroll? List the numbers separated by spaces.");
50 50
                 }
51 51
                 rollOptions(rollChoice, diceToRoll); }
52 52
 

+ 34
- 15
src/test/java/io/zipcoder/casino/CardTest.java Ver arquivo

@@ -1,22 +1,41 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
+import org.junit.Assert;
3 4
 import org.junit.Test;
4 5
 
5
-import javax.smartcardio.Card;
6
-
7 6
 public class CardTest {
8 7
 
9
-//    @Test
10
-//    public void createCard(){
11
-//        Card card = new Card(Card.CardValue.TWO, Card.Suit.CLUBS);
12
-//        System.out.println(card.getName());
13
-//    }
14
-//
15
-//    @Test
16
-//    public void createCard2(){
17
-//        Card card = new Card(Card.CardValue.TWO, Card.Suit.CLUBS);
18
-//        Card card1 = new Card(Card.CardValue.QUEEN, Card.Suit.HEARTS);
19
-//        System.out.println(card.getName());
20
-//        System.out.println(card1.getName());
21
-//    }
8
+    @Test
9
+    public void testCreateCard(){
10
+        Card card = new Card(Card.CardValue.TWO, Card.Suit.CLUBS);
11
+        String expected = "TWO of CLUBS";
12
+        String actual = card.getName();
13
+        Assert.assertEquals(expected, actual);
14
+    }
15
+
16
+    @Test
17
+    public void testGetSuit(){
18
+        Card card = new Card(Card.CardValue.THREE, Card.Suit.DIAMONDS);
19
+        Card.Suit expected = Card.Suit.DIAMONDS;
20
+        Card.Suit actual = card.getSuit();
21
+        Assert.assertEquals(expected, actual);
22
+    }
23
+
24
+    @Test
25
+    public void testGetCardValue(){
26
+        Card card = new Card(Card.CardValue.ACE, Card.Suit.HEARTS);
27
+        int expected = 14;
28
+        int actual = card.getCardValue();
29
+        Assert.assertEquals(expected, actual);
30
+    }
31
+
32
+    @Test
33
+    public void testVisibility(){
34
+        Card card = new Card(Card.CardValue.KING, Card.Suit.SPADES);
35
+        boolean before = card.isVisible();
36
+        card.setVisibility(true);
37
+        boolean after = card.isVisible();
38
+        Assert.assertNotEquals(before, after);
39
+    }
40
+
22 41
 }

+ 56
- 3
src/test/java/io/zipcoder/casino/SlotTest.java Ver arquivo

@@ -4,20 +4,23 @@ package io.zipcoder.casino;
4 4
 import org.junit.Before;
5 5
 import org.junit.Test;
6 6
 import org.junit.Assert;
7
-
8 7
 import java.util.Random;
9 8
 
10 9
 
10
+
11 11
 public class SlotTest {
12 12
     private int betAmount = 10;
13 13
     private SlotMachine slotmachine = new SlotMachine(betAmount);
14 14
 
15
+    Player player = new Player("Bob", 400);
16
+
15 17
     @Test
16 18
     public void testSlotResult1(){
17 19
         String word1="MOUSE";
18 20
         String word2="MOUSE";
19 21
         String word3="MOUSE";
20 22
         //given
23
+        SlotMachine slotmachine = new SlotMachine(betAmount, player);
21 24
         slotmachine.setWord1(word1);
22 25
         slotmachine.setWord2(word2);
23 26
         slotmachine.setWord3(word3);
@@ -36,6 +39,7 @@ public class SlotTest {
36 39
 
37 40
 
38 41
         //given
42
+        SlotMachine slotmachine = new SlotMachine(betAmount, player);
39 43
         slotmachine.setWord1(word1);
40 44
         slotmachine.setWord2(word2);
41 45
         slotmachine.setWord3(word3);
@@ -54,7 +58,7 @@ public class SlotTest {
54 58
         String word3="CAT";
55 59
 
56 60
         //given
57
-        SlotMachine slotmachine = new SlotMachine(betAmount);
61
+        SlotMachine slotmachine = new SlotMachine(betAmount, player);
58 62
 
59 63
         slotmachine.setWord1(word1);
60 64
         slotmachine.setWord2(word2);
@@ -63,6 +67,55 @@ public class SlotTest {
63 67
         slotmachine.slotResult();
64 68
         int payout=slotmachine.getPayoutAmt();
65 69
         Assert.assertEquals(0,payout);
70
+    }
71
+
72
+    @Test
73
+    public void testGenerateWords() {
74
+        //Given
75
+        SlotMachine game = new SlotMachine(100, player);
76
+        String before = game.getOutputword();
77
+
78
+        //When
79
+        game.generateWords();
80
+        String after = game.getOutputword();
81
+
82
+        //Then
83
+        Assert.assertNotEquals(before, after);
84
+
85
+
86
+    }
87
+
88
+    @Test
89
+    public void testBet() {
90
+        //Given
91
+        SlotMachine game = new SlotMachine(100, player);
92
+        int expected = 300;
93
+
94
+        //When
95
+        game.bet(100);
96
+        int actual = game.getPlayer().getCurrentBalance();
97
+
98
+        //Then
99
+        Assert.assertEquals(expected, actual);
100
+
101
+
102
+    }
103
+
104
+    @Test
105
+    public void testPayout() {
106
+        //Given
107
+        SlotMachine game = new SlotMachine(100, player);
108
+        int expected = 500;
109
+
110
+        //When
111
+        game.bet(100);
112
+        game.setPayoutAmt(200);
113
+        game.payout();
114
+        int actual = game.getPlayer().getCurrentBalance();
115
+
116
+        //Then
117
+        Assert.assertEquals(expected, actual);
118
+
66 119
 
67 120
     }
68 121
 
@@ -82,7 +135,7 @@ public class SlotTest {
82 135
     }
83 136
 
84 137
     @Test
85
-    public void testGenerateWords(){
138
+    public void testGenerateWords2(){
86 139
         Random random = new Random(1);
87 140
 
88 141
 

+ 29
- 8
src/test/java/io/zipcoder/casino/StudTest.java Ver arquivo

@@ -28,6 +28,7 @@ public class StudTest {
28 28
         cardsTest1.add(cardSix); cardsTest1.add(cardFive); cardsTest1.add(cardFour);
29 29
         this.cardPlayer1.setHand(cardsTest1);
30 30
 
31
+
31 32
         ArrayList<Card> cardsTest2 = new ArrayList<>();
32 33
         Player player2 = new Player("Player2", 10);
33 34
         this.cardPlayer2 = new CardPlayer(player2);
@@ -40,6 +41,8 @@ public class StudTest {
40 41
         players.add(this.cardPlayer1);
41 42
         players.add(this.cardPlayer2);
42 43
 
44
+        stud.addPlayers(player1, player2);
45
+
43 46
     }
44 47
 
45 48
     @Test
@@ -237,19 +240,15 @@ public class StudTest {
237 240
         boolean expected = true;
238 241
         //THEN
239 242
         boolean actual = stud.getIsDealt();
240
-
241 243
         Assert.assertEquals(expected, actual);
242 244
     }
243 245
 
244 246
     @Test //Either payAnte or Test is broken, Ante is not deducted. Test set to pass
245 247
     public void payAnteTest(){
246
-        stud.payAnte(players);
247
-        //WHEN @Before
248
-        int expected = 10;
249
-        //THEN
250
-        int actual = players.get(0).getPlayer().getCurrentBalance();
251
-
252
-        Assert.assertEquals(expected, actual);
248
+       stud.payAnte(stud.getPlayers());
249
+       int expect = 0;
250
+       int actual = stud.getPlayers().get(0).getPlayer().getCurrentBalance();
251
+       Assert.assertEquals(expect, actual);
253 252
     }
254 253
 
255 254
     @Test
@@ -273,6 +272,28 @@ public class StudTest {
273 272
 
274 273
         Assert.assertEquals(expected, actual);
275 274
     }
275
+
276
+//    @Test
277
+//    public void testStartRound(){
278
+//
279
+//        String input = "flip \n";
280
+//        stud.deal(players);
281
+//        System.out.println(players.get(0).getHand().size());
282
+//
283
+//        //System.out.println(cardPlayer1.getHand().size());
284
+//
285
+//        stud.setScanner(new Scanner(new ByteArrayInputStream(input.getBytes())));
286
+//        try {
287
+//            stud.startRound();
288
+//        } catch (NoSuchElementException e) {
289
+//
290
+//        }
291
+//
292
+//
293
+//
294
+//
295
+//        //Assert.assertTrue(war.getPlayersTurn() instanceof CardPlayer);
296
+//    }
276 297
 }
277 298
 /*
278 299
     CODE FOR TRASH PANDAS

+ 119
- 2
src/test/java/io/zipcoder/casino/WarTest.java Ver arquivo

@@ -3,6 +3,11 @@ package io.zipcoder.casino;
3 3
 import org.junit.Assert;
4 4
 import org.junit.Test;
5 5
 
6
+import java.io.ByteArrayInputStream;
7
+import java.util.ArrayList;
8
+import java.util.NoSuchElementException;
9
+import java.util.Scanner;
10
+
6 11
 public class WarTest {
7 12
 
8 13
     @Test
@@ -20,7 +25,7 @@ public class WarTest {
20 25
         War war = new War(10);
21 26
         Player player = new Player("Jon", 100);
22 27
         war.addPlayers(player);
23
-        war.chooseStatingPlayer();
28
+        war.chooseStartingPlayer();
24 29
         war.deal();
25 30
         war.getPlayers().get(0).setDiscard(deck);
26 31
 
@@ -34,10 +39,122 @@ public class WarTest {
34 39
         War war = new War(10);
35 40
         Player player = new Player("Jon", 100);
36 41
         war.addPlayers(player);
37
-        war.chooseStatingPlayer();
42
+        war.chooseStartingPlayer();
38 43
         war.playCard(false);
39 44
 
40 45
         Assert.assertEquals(war.getLoser(), player);
41 46
     }
42 47
 
48
+    @Test
49
+    public void warDealTest(){
50
+        War war = new War(10);
51
+        war.addPlayers(new Player("Jon", 100));
52
+        war.chooseStartingPlayer();
53
+        war.deal();
54
+
55
+        Assert.assertTrue(war.getPlayers().get(0).getHand().size() == 52);
56
+    }
57
+
58
+    @Test
59
+    public void warEachPlayerPlayCardTest(){
60
+        War war = new War(10);
61
+        war.addPlayers(new Player("Jon", 100), new Player("Jose", 200));
62
+
63
+        war.chooseStartingPlayer();
64
+        war.deal();
65
+        war.eachPlayerPlayCard();
66
+
67
+        int toalHand = 0;
68
+
69
+        for(CardPlayer player : war.getPlayers()){
70
+            toalHand += player.getHand().size();
71
+        }
72
+        Assert.assertTrue(toalHand == 50);
73
+    }
74
+
75
+    @Test
76
+    public void testWarStartGame(){
77
+        War war = new War(10);
78
+        Player player1 = new Player("Jose", 100);
79
+        Player player2 = new Player("Lauren", 200);
80
+        war.addPlayers(player1, player2);
81
+        war.chooseStartingPlayer();
82
+        war.deal();
83
+
84
+        String input = "flip \n";
85
+
86
+
87
+            war.setScanner(new Scanner(new ByteArrayInputStream(input.getBytes())));
88
+            try {
89
+                war.startGame();
90
+            } catch (NoSuchElementException e) {
91
+
92
+            }
93
+
94
+
95
+        Assert.assertTrue(war.getPlayersTurn() instanceof CardPlayer);
96
+    }
97
+
98
+    @Test
99
+    public void testWarQuit(){
100
+        War war = new War(10);
101
+        Player player1 = new Player("Jose", 100);
102
+        Player player2 = new Player("Lauren", 200);
103
+        war.addPlayers(player1, player2);
104
+        war.chooseStartingPlayer();
105
+        CardPlayer startPlayer = war.getPlayersTurn();
106
+        war.deal();
107
+
108
+        String input = "quit \n";
109
+
110
+
111
+        war.setScanner(new Scanner(new ByteArrayInputStream(input.getBytes())));
112
+        try {
113
+            war.startGame();
114
+        } catch (NoSuchElementException e) {
115
+
116
+        }
117
+
118
+
119
+       Assert.assertTrue(war.getPlayersTurn() == startPlayer);
120
+    }
121
+
122
+    @Test
123
+    public void testWarMethod(){
124
+        War war = new War(10);
125
+        Player player1 = new Player("Jose", 100);
126
+        Player player2 = new Player("Lauren", 200);
127
+        war.addPlayers(player1, player2);
128
+        war.chooseStartingPlayer();
129
+        CardPlayer startPlayer = war.getPlayersTurn();
130
+
131
+        ArrayList<Card> hand1 = new ArrayList<>();
132
+        hand1.add(new Card(Card.CardValue.FOUR, Card.Suit.HEARTS));
133
+        hand1.add(new Card(Card.CardValue.FOUR, Card.Suit.HEARTS));
134
+        hand1.add(new Card(Card.CardValue.THREE, Card.Suit.HEARTS));
135
+        hand1.add(new Card(Card.CardValue.TWO, Card.Suit.HEARTS));
136
+        hand1.add(new Card(Card.CardValue.ACE, Card.Suit.HEARTS));
137
+
138
+        ArrayList<Card> hand2 = new ArrayList<>();
139
+        hand2.add(new Card(Card.CardValue.FOUR, Card.Suit.HEARTS));
140
+        hand2.add(new Card(Card.CardValue.KING, Card.Suit.HEARTS));
141
+        hand2.add(new Card(Card.CardValue.JACK, Card.Suit.HEARTS));
142
+        hand2.add(new Card(Card.CardValue.QUEEN, Card.Suit.HEARTS));
143
+        hand2.add(new Card(Card.CardValue.KING, Card.Suit.HEARTS));
144
+
145
+        String input = "flip \n";
146
+
147
+        war.getPlayers().get(0).setHand(hand1);
148
+        war.getPlayers().get(1).setHand(hand2);
149
+
150
+        war.setScanner(new Scanner(new ByteArrayInputStream(input.getBytes())));
151
+        try {
152
+            war.startRound();
153
+        } catch (NoSuchElementException e) {
154
+
155
+        }
156
+
157
+        Assert.assertTrue(war.getPlayers().get(0).getHand().size() == 1);
158
+    }
159
+
43 160
 }