Pārlūkot izejas kodu

Merge branch 'newstud' of nsatinover/ZCW-OOP-Casino into working

jonathan-hinds 6 gadus atpakaļ
vecāks
revīzija
a0710031e4

+ 1
- 9
src/main/java/io/zipcoder/casino/CardGame.java Parādīt failu

@@ -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,11 +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
-
31 24
     public Deck getDeck() {
32 25
         return deck;
33 26
     }
@@ -43,7 +36,6 @@ public abstract class CardGame {
43 36
         }
44 37
     }
45 38
 
46
-
47 39
     public int getAnte(){
48 40
         return ante;
49 41
     }
@@ -80,7 +72,7 @@ public abstract class CardGame {
80 72
         addPlayers(new NPC("Opponant", getAnte()));
81 73
     }
82 74
 
83
-    public void chooseStatingPlayer(){
75
+    public void chooseStartingPlayer(){
84 76
         //loop through the players
85 77
         for(int i = 0; i < getPlayers().size(); i ++){
86 78
             //if one is not an NPC

+ 7
- 9
src/main/java/io/zipcoder/casino/Stud.java Parādīt failu

@@ -17,12 +17,10 @@ public class Stud extends CardGame implements Game {
17 17
         Printer.printMessage(player.getName() + " shows a " + card.getName());         //PRINT card name to CONSOLE
18 18
     }
19 19
 
20
-
21 20
     public boolean getIsDealt(){
22 21
         return isDealt;
23 22
     }
24 23
 
25
-
26 24
     /**
27 25
      * Determine what player wins by looping through player array and then
28 26
      * passing each hand to the 'handValue' method
@@ -143,10 +141,10 @@ public class Stud extends CardGame implements Game {
143 141
     }
144 142
 
145 143
     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
144
+        setHandSize(3);                 //SET Hand Size for game(3)
145
+        payAnte(this.getPlayers());     //PAY ante (all players)
146
+        deal(this.getPlayers());        //DEALS cards/ hands to each player
147
+        startRound();                   //METHOD called
150 148
 
151 149
     }
152 150
 
@@ -179,9 +177,9 @@ public class Stud extends CardGame implements Game {
179 177
      * Deal each player(and dealer) 3 face down cards in turn
180 178
      */
181 179
     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
180
+        for(int i = 0; i < getHandSize(); i ++){
181
+            for (int j = 0; j < players.size(); j++) {
182
+                players.get(j).getHand().add(getDeck().pullCard());
185 183
             }
186 184
         }
187 185
         isDealt = true;

+ 1
- 6
src/main/java/io/zipcoder/casino/War.java Parādīt failu

@@ -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
 
@@ -117,7 +112,7 @@ public class War extends CardGame implements Gamble, Game {
117 112
 
118 113
     public void startGame(){
119 114
         Printer.printMessage("Welcome to War!");
120
-        super.chooseStatingPlayer();
115
+        super.chooseStartingPlayer();
121 116
         payAnte();
122 117
         deal();
123 118
         startRound();

+ 1
- 0
src/test/java/io/zipcoder/casino/CardTest.java Parādīt failu

@@ -37,4 +37,5 @@ public class CardTest {
37 37
         boolean after = card.isVisible();
38 38
         Assert.assertNotEquals(before, after);
39 39
     }
40
+
40 41
 }

+ 1
- 1
src/test/java/io/zipcoder/casino/StudTest.java Parādīt failu

@@ -246,7 +246,7 @@ public class StudTest {
246 246
         stud.payAnte(players);
247 247
         System.out.println(players.get(0).getPlayer().getCurrentBalance());
248 248
         //WHEN @Before
249
-        int expected = 10;
249
+        int expected = 0;
250 250
         //THEN
251 251
         int actual = players.get(0).getPlayer().getCurrentBalance();
252 252
 

+ 2
- 2
src/test/java/io/zipcoder/casino/WarTest.java Parādīt failu

@@ -25,7 +25,7 @@ public class WarTest {
25 25
         War war = new War(10);
26 26
         Player player = new Player("Jon", 100);
27 27
         war.addPlayers(player);
28
-        war.chooseStatingPlayer();
28
+        war.chooseStartingPlayer();
29 29
         war.deal();
30 30
         war.getPlayers().get(0).setDiscard(deck);
31 31
 
@@ -39,7 +39,7 @@ public class WarTest {
39 39
         War war = new War(10);
40 40
         Player player = new Player("Jon", 100);
41 41
         war.addPlayers(player);
42
-        war.chooseStatingPlayer();
42
+        war.chooseStartingPlayer();
43 43
         war.playCard(false);
44 44
 
45 45
         Assert.assertEquals(war.getLoser(), player);