ソースを参照

stud ante method tested

Jonathan Hinds 6 年 前
コミット
4f2be4d802

+ 7
- 3
src/main/java/io/zipcoder/casino/Stud.java ファイルの表示

@@ -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();
@@ -136,7 +137,9 @@ public class Stud extends CardGame implements Game {
136 137
     public void payAnte(ArrayList<CardPlayer> players) {
137 138
         for(int i = 0; i < super.getPlayers().size(); i ++)
138 139
         {
139
-            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());
140 143
         }
141 144
     }
142 145
 
@@ -200,7 +203,8 @@ public class Stud extends CardGame implements Game {
200 203
         return isCardFlipped;
201 204
     }
202 205
 
203
-    public void quit() {}
204
-    // public void payout(){ }
206
+    public void setScanner(Scanner scanner){
207
+        this.console.setScanner(scanner);
208
+    }
205 209
 }
206 210
 

+ 4
- 0
src/test/java/io/zipcoder/casino/SlotTest.java ファイルの表示

@@ -4,6 +4,10 @@ package io.zipcoder.casino;
4 4
 import org.junit.Test;
5 5
 import org.junit.Assert;
6 6
 
7
+import java.io.ByteArrayInputStream;
8
+import java.util.NoSuchElementException;
9
+import java.util.Scanner;
10
+
7 11
 
8 12
 public class SlotTest {
9 13
 

+ 29
- 9
src/test/java/io/zipcoder/casino/StudTest.java ファイルの表示

@@ -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,20 +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
-        System.out.println(players.get(0).getPlayer().getCurrentBalance());
248
-        //WHEN @Before
249
-        int expected = 0;
250
-        //THEN
251
-        int actual = players.get(0).getPlayer().getCurrentBalance();
252
-
253
-        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);
254 252
     }
255 253
 
256 254
     @Test
@@ -274,6 +272,28 @@ public class StudTest {
274 272
 
275 273
         Assert.assertEquals(expected, actual);
276 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
+//    }
277 297
 }
278 298
 /*
279 299
     CODE FOR TRASH PANDAS

+ 5
- 5
src/test/java/io/zipcoder/casino/WarTest.java ファイルの表示

@@ -49,7 +49,7 @@ public class WarTest {
49 49
     public void warDealTest(){
50 50
         War war = new War(10);
51 51
         war.addPlayers(new Player("Jon", 100));
52
-        war.chooseStatingPlayer();
52
+        war.chooseStartingPlayer();
53 53
         war.deal();
54 54
 
55 55
         Assert.assertTrue(war.getPlayers().get(0).getHand().size() == 52);
@@ -60,7 +60,7 @@ public class WarTest {
60 60
         War war = new War(10);
61 61
         war.addPlayers(new Player("Jon", 100), new Player("Jose", 200));
62 62
 
63
-        war.chooseStatingPlayer();
63
+        war.chooseStartingPlayer();
64 64
         war.deal();
65 65
         war.eachPlayerPlayCard();
66 66
 
@@ -78,7 +78,7 @@ public class WarTest {
78 78
         Player player1 = new Player("Jose", 100);
79 79
         Player player2 = new Player("Lauren", 200);
80 80
         war.addPlayers(player1, player2);
81
-        war.chooseStatingPlayer();
81
+        war.chooseStartingPlayer();
82 82
         war.deal();
83 83
 
84 84
         String input = "flip \n";
@@ -101,7 +101,7 @@ public class WarTest {
101 101
         Player player1 = new Player("Jose", 100);
102 102
         Player player2 = new Player("Lauren", 200);
103 103
         war.addPlayers(player1, player2);
104
-        war.chooseStatingPlayer();
104
+        war.chooseStartingPlayer();
105 105
         CardPlayer startPlayer = war.getPlayersTurn();
106 106
         war.deal();
107 107
 
@@ -125,7 +125,7 @@ public class WarTest {
125 125
         Player player1 = new Player("Jose", 100);
126 126
         Player player2 = new Player("Lauren", 200);
127 127
         war.addPlayers(player1, player2);
128
-        war.chooseStatingPlayer();
128
+        war.chooseStartingPlayer();
129 129
         CardPlayer startPlayer = war.getPlayersTurn();
130 130
 
131 131
         ArrayList<Card> hand1 = new ArrayList<>();