|
@@ -3,11 +3,7 @@ package io.zipcoder.casino;
|
3
|
3
|
import org.junit.Assert;
|
4
|
4
|
import org.junit.Before;
|
5
|
5
|
import org.junit.Test;
|
6
|
|
-
|
7
|
|
-import java.io.ByteArrayInputStream;
|
8
|
6
|
import java.util.ArrayList;
|
9
|
|
-import java.util.NoSuchElementException;
|
10
|
|
-import java.util.Scanner;
|
11
|
7
|
|
12
|
8
|
public class StudTest {
|
13
|
9
|
|
|
@@ -241,18 +237,6 @@ public class StudTest {
|
241
|
237
|
Assert.assertEquals(expected, actual);
|
242
|
238
|
}
|
243
|
239
|
|
244
|
|
- @Test //Either payAnte or Test is broken, Ante is not deducted. Test set to pass
|
245
|
|
- 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);
|
254
|
|
- }
|
255
|
|
-
|
256
|
240
|
@Test
|
257
|
241
|
public void playCardTest(){
|
258
|
242
|
stud.playCard(cardPlayer1.getPlayer(), cardPlayer1.getHand().get(0));
|
|
@@ -274,86 +258,37 @@ public class StudTest {
|
274
|
258
|
|
275
|
259
|
Assert.assertEquals(expected, actual);
|
276
|
260
|
}
|
277
|
|
-}
|
278
|
|
-/*
|
279
|
|
- CODE FOR TRASH PANDAS
|
280
|
261
|
|
281
|
262
|
@Test
|
282
|
|
- public void flipCardTest(){
|
283
|
|
- stud.deal();
|
|
263
|
+ public void tableTest(){
|
|
264
|
+ stud.changeTablePot(10);
|
284
|
265
|
//WHEN @Before
|
285
|
|
- boolean expected = false;
|
|
266
|
+ int expected = 10;
|
286
|
267
|
//THEN
|
287
|
|
- boolean actual = stud.flipCard();
|
|
268
|
+ int actual = stud.getTablePot();
|
288
|
269
|
|
289
|
270
|
Assert.assertEquals(expected, actual);
|
290
|
271
|
}
|
291
|
272
|
|
292
|
|
- public CardPlayer determineWinner(ArrayList<CardPlayer> players){
|
293
|
|
- int max = 0;
|
294
|
|
- CardPlayer winner = null;
|
295
|
|
-
|
296
|
|
- for(int i = 0; i < players.size(); i ++){
|
297
|
|
- CardPlayer player = players.get(i);
|
298
|
|
- int playerHandValue = handValue(player); // 'handValue' method sets 'max' value of this hand
|
299
|
|
- if(playerHandValue > max){
|
300
|
|
- max = playerHandValue;
|
301
|
|
- winner = player;
|
302
|
|
- }
|
303
|
|
- }
|
304
|
|
- System.out.println("The winner is " + winner.getPlayer().getName());
|
305
|
|
- System.out.println(winner.getPlayer().getName() + "\'s hand was: " + winner.getHand().get(0).getName() +
|
306
|
|
- " - " + winner.getHand().get(1).getName() + " - " + winner.getHand().get(2).getName() + "\n\n" );
|
307
|
|
- return winner;
|
308
|
|
- }
|
309
|
|
-
|
310
|
|
- public CardPlayer determineWinner(){
|
311
|
|
- int max = 0;
|
312
|
|
- CardPlayer winner = null;
|
313
|
|
-
|
314
|
|
- for(int i = 0; i < getPlayers().size(); i ++){
|
315
|
|
- CardPlayer player = getPlayers().get(i);
|
316
|
|
- int playerHandValue = handValue(player); // 'handValue' method sets 'max' value of this hand
|
317
|
|
- if(playerHandValue > max){
|
318
|
|
- max = playerHandValue;
|
319
|
|
- winner = player;
|
320
|
|
- }
|
321
|
|
- }
|
322
|
|
- System.out.println("The winner is " + winner.getPlayer().getName());
|
323
|
|
- System.out.println(winner.getPlayer().getName() + "\'s hand was: " + winner.getHand().get(0).getName() +
|
324
|
|
- " - " + winner.getHand().get(1).getName() + " - " + winner.getHand().get(2).getName() + "\n\n" );
|
325
|
|
- return winner;
|
326
|
|
- }
|
327
|
|
-
|
328
|
|
- public void startRound() {
|
329
|
|
- System.out.println("Welcome to Three Card Stud! Cards are dealt!");
|
330
|
|
- flipCard();
|
331
|
|
- gameRound();
|
332
|
|
- flipCard();
|
333
|
|
- gameRound2();
|
334
|
|
- flipCard();
|
335
|
|
- lastGameRound();
|
336
|
|
- determineWinner(this.getPlayers()); //TEST ADDED ARGUMENT
|
337
|
|
- }
|
|
273
|
+ @Test
|
|
274
|
+ public void setHandSizeTest(){
|
|
275
|
+ stud.setHandSize(5);
|
|
276
|
+ //WHEN @Before
|
|
277
|
+ int expected = 5;
|
|
278
|
+ //THEN
|
|
279
|
+ int actual = stud.getHandSize();
|
338
|
280
|
|
339
|
|
- /*
|
340
|
|
- public void payAnte() {
|
341
|
|
- for(int i = 0; i < super.getPlayers().size(); i ++)
|
342
|
|
- {
|
343
|
|
- CardPlayer player = super.getPlayers().get(i);
|
344
|
|
- player.getPlayer().changeBalance(-super.getAnte());
|
345
|
|
- }
|
|
281
|
+ Assert.assertEquals(expected, actual);
|
346
|
282
|
}
|
347
|
283
|
|
348
|
|
- * PreCondition: Betting rounds already played
|
349
|
|
- * Plays through round that include flipping last card face up
|
350
|
|
- * PostCondtion: tablePot is now at max value
|
351
|
|
- * DetermineWinner() expected to be called after this method
|
|
284
|
+ @Test
|
|
285
|
+ public void setPlayersTurnTest(){
|
|
286
|
+ stud.setPlayersTurn(cardPlayer1);
|
|
287
|
+ //WHEN @Before
|
|
288
|
+ CardPlayer expected = cardPlayer1;
|
|
289
|
+ //THEN
|
|
290
|
+ CardPlayer actual = stud.getPlayersTurn();
|
352
|
291
|
|
353
|
|
-public void lastGameRound(){
|
354
|
|
- for (int j = 0; j < getPlayers().size(); j++) {
|
355
|
|
- CardPlayer player = super.getPlayers().get(j); //GET a player
|
356
|
|
- playCard(player.getPlayer(), player.getHand().get(2)); //SHOW-PRINT players first CARD
|
|
292
|
+ Assert.assertEquals(expected, actual);
|
357
|
293
|
}
|
358
|
294
|
}
|
359
|
|
-*/
|