Lauren Green пре 6 година
родитељ
комит
0cb866264e

+ 0
- 5
src/main/java/io/zipcoder/casino/CardGame.java Прегледај датотеку

27
     // public abstract void deal();
27
     // public abstract void deal();
28
     // public abstract void deal(ArrayList<CardPlayer> players); // NEEDED FOR STUD
28
     // public abstract void deal(ArrayList<CardPlayer> players); // NEEDED FOR STUD
29
 
29
 
30
-    public void shuffle(){
31
-
32
-        //shuffle the card stack
33
-
34
-    }
35
 
30
 
36
     public Deck getDeck() {
31
     public Deck getDeck() {
37
         return deck;
32
         return deck;

+ 8
- 3
src/main/java/io/zipcoder/casino/War.java Прегледај датотеку

134
                 Printer.printMessage(winner.getPlayer().getName() + " has been rewarded " + tableCards.size() + " cards.");
134
                 Printer.printMessage(winner.getPlayer().getName() + " has been rewarded " + tableCards.size() + " cards.");
135
                 winner.addDiscard(tableCards);
135
                 winner.addDiscard(tableCards);
136
                 tableCards = new ArrayList<Card>();
136
                 tableCards = new ArrayList<Card>();
137
-            }else if(input.equals("quit")){
138
-                Printer.printMessage("Thanks for playing chump!");
139
-                console.getScanner().close();
140
             } else {
137
             } else {
141
                 Printer.printMessage("Sorry, I don't understand that command.");
138
                 Printer.printMessage("Sorry, I don't understand that command.");
142
             }
139
             }
162
         }
159
         }
163
         Printer.printMessage(super.getPlayersTurn().getPlayer().getName() + "has: " + super.getPlayersTurn().getHand().size() + " cards.");
160
         Printer.printMessage(super.getPlayersTurn().getPlayer().getName() + "has: " + super.getPlayersTurn().getHand().size() + " cards.");
164
     }
161
     }
162
+
163
+    public void setScanner(Scanner scanner) {
164
+        this.console.setScanner(scanner);
165
+    }
166
+
167
+    public ArrayList<CardPlayer> getWarMembers() {
168
+        return warMembers;
169
+    }
165
 }
170
 }

+ 0
- 1
src/test/java/io/zipcoder/casino/SlotTest.java Прегледај датотеку

63
         slotmachine.slotResult();
63
         slotmachine.slotResult();
64
         int payout=slotmachine.getPayoutAmt();
64
         int payout=slotmachine.getPayoutAmt();
65
         Assert.assertEquals(0,payout);
65
         Assert.assertEquals(0,payout);
66
-
67
     }
66
     }
68
 }
67
 }

+ 1
- 0
src/test/java/io/zipcoder/casino/StudTest.java Прегледај датотеку

244
     @Test //Either payAnte or Test is broken, Ante is not deducted. Test set to pass
244
     @Test //Either payAnte or Test is broken, Ante is not deducted. Test set to pass
245
     public void payAnteTest(){
245
     public void payAnteTest(){
246
         stud.payAnte(players);
246
         stud.payAnte(players);
247
+        System.out.println(players.get(0).getPlayer().getCurrentBalance());
247
         //WHEN @Before
248
         //WHEN @Before
248
         int expected = 10;
249
         int expected = 10;
249
         //THEN
250
         //THEN

+ 117
- 0
src/test/java/io/zipcoder/casino/WarTest.java Прегледај датотеку

3
 import org.junit.Assert;
3
 import org.junit.Assert;
4
 import org.junit.Test;
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
 public class WarTest {
11
 public class WarTest {
7
 
12
 
8
     @Test
13
     @Test
40
         Assert.assertEquals(war.getLoser(), player);
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.chooseStatingPlayer();
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.chooseStatingPlayer();
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.chooseStatingPlayer();
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.chooseStatingPlayer();
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.chooseStatingPlayer();
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
 }