Sfoglia il codice sorgente

stud ante method tested

Jonathan Hinds 6 anni fa
parent
commit
4f2be4d802

+ 7
- 3
src/main/java/io/zipcoder/casino/Stud.java Vedi File

1
 package io.zipcoder.casino;
1
 package io.zipcoder.casino;
2
 
2
 
3
 import java.util.ArrayList;
3
 import java.util.ArrayList;
4
+import java.util.Scanner;
4
 
5
 
5
 public class Stud extends CardGame implements Game {
6
 public class Stud extends CardGame implements Game {
6
     Console console = new Console();
7
     Console console = new Console();
136
     public void payAnte(ArrayList<CardPlayer> players) {
137
     public void payAnte(ArrayList<CardPlayer> players) {
137
         for(int i = 0; i < super.getPlayers().size(); i ++)
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
         return isCardFlipped;
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 Vedi File

4
 import org.junit.Test;
4
 import org.junit.Test;
5
 import org.junit.Assert;
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
 public class SlotTest {
12
 public class SlotTest {
9
 
13
 

+ 29
- 9
src/test/java/io/zipcoder/casino/StudTest.java Vedi File

28
         cardsTest1.add(cardSix); cardsTest1.add(cardFive); cardsTest1.add(cardFour);
28
         cardsTest1.add(cardSix); cardsTest1.add(cardFive); cardsTest1.add(cardFour);
29
         this.cardPlayer1.setHand(cardsTest1);
29
         this.cardPlayer1.setHand(cardsTest1);
30
 
30
 
31
+
31
         ArrayList<Card> cardsTest2 = new ArrayList<>();
32
         ArrayList<Card> cardsTest2 = new ArrayList<>();
32
         Player player2 = new Player("Player2", 10);
33
         Player player2 = new Player("Player2", 10);
33
         this.cardPlayer2 = new CardPlayer(player2);
34
         this.cardPlayer2 = new CardPlayer(player2);
40
         players.add(this.cardPlayer1);
41
         players.add(this.cardPlayer1);
41
         players.add(this.cardPlayer2);
42
         players.add(this.cardPlayer2);
42
 
43
 
44
+        stud.addPlayers(player1, player2);
45
+
43
     }
46
     }
44
 
47
 
45
     @Test
48
     @Test
237
         boolean expected = true;
240
         boolean expected = true;
238
         //THEN
241
         //THEN
239
         boolean actual = stud.getIsDealt();
242
         boolean actual = stud.getIsDealt();
240
-
241
         Assert.assertEquals(expected, actual);
243
         Assert.assertEquals(expected, actual);
242
     }
244
     }
243
 
245
 
244
     @Test //Either payAnte or Test is broken, Ante is not deducted. Test set to pass
246
     @Test //Either payAnte or Test is broken, Ante is not deducted. Test set to pass
245
     public void payAnteTest(){
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
     @Test
254
     @Test
274
 
272
 
275
         Assert.assertEquals(expected, actual);
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
     CODE FOR TRASH PANDAS
299
     CODE FOR TRASH PANDAS

+ 5
- 5
src/test/java/io/zipcoder/casino/WarTest.java Vedi File

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