Lauren Green 6 år sedan
förälder
incheckning
0262b67df4

Binär
.DS_Store Visa fil


Binär
src/.DS_Store Visa fil


Binär
src/main/.DS_Store Visa fil


Binär
src/main/java/.DS_Store Visa fil


Binär
src/main/java/io/.DS_Store Visa fil


Binär
src/main/java/io/zipcoder/.DS_Store Visa fil


+ 1
- 3
src/main/java/io/zipcoder/casino/CardGame.java Visa fil

@@ -19,9 +19,7 @@ public abstract class CardGame {
19 19
     private Deck deck = new Deck();
20 20
 
21 21
 
22
-    CardGame(int minBet, int maxBet, int ante){
23
-        this.minBet = minBet;
24
-        this.maxBet = maxBet;
22
+    CardGame(int ante){
25 23
         this.ante = ante;
26 24
     }
27 25
 

+ 2
- 44
src/main/java/io/zipcoder/casino/Console.java Visa fil

@@ -47,16 +47,14 @@ public class Console {
47 47
             switch (command) {
48 48
 
49 49
                 case "war":
50
-                    int[] warMinMax = getMinMax();
51
-                    Game war = new War(warMinMax[0], warMinMax[1], 10);
50
+                    Game war = new War(10);
52 51
                     ((War) war).addPlayers(players.get(0));
53 52
                     ((War) war).addNpc();
54 53
                     war.startGame();
55 54
                     break;
56 55
 
57 56
                 case "stud":
58
-                    int[] studMinMax = getMinMax();
59
-                    Game stud = new Stud(studMinMax[0], studMinMax[1], 10);
57
+                    Game stud = new Stud( 10);
60 58
                     ((Stud) stud).addPlayers(players.get(0));
61 59
                     addStudPlayers(stud);
62 60
                     stud.startGame();
@@ -90,28 +88,6 @@ public class Console {
90 88
         return -1;
91 89
     }
92 90
 
93
-    public int[] getMinMax(){
94
-        Printer.getBet("minimum bet");
95
-        int min = 0;
96
-        while(min <= 0){
97
-            min = getIntFromUser();
98
-            if(min < 0){
99
-                Printer.unacceptableMinBet();
100
-            }
101
-        }
102
-
103
-        Printer.getBet("maximum bet");
104
-        int max = 0;
105
-        while(max < min) {
106
-            max = getIntFromUser();
107
-            if(max < min){
108
-                Printer.unacceptableMaxBet(min);
109
-            }
110
-        }
111
-        int[] minMax = {min, max};
112
-        return minMax;
113
-    }
114
-
115 91
     public String getCommand() {
116 92
         String command = "";
117 93
         String input = scanner.next();
@@ -127,24 +103,6 @@ public class Console {
127 103
         return command;
128 104
     }
129 105
 
130
-    public String continueAskGame(){
131
-
132
-        String command = "";
133
-
134
-        System.out.println("Please choose a game to play!");
135
-        command = getCommand();
136
-
137
-        if(gameLib.indexOf(command) == -1)
138
-        {
139
-            while(gameLib.indexOf(command) == -1)
140
-            {
141
-                Printer.noMatchingGameName(gameLib);
142
-                command = getCommand();
143
-            }
144
-        }
145
-        return command;
146
-    }
147
-
148 106
     public int getStudPlayers() {
149 107
         int numOfStudPlayers = 0;
150 108
 

+ 13
- 7
src/main/java/io/zipcoder/casino/Stud.java Visa fil

@@ -6,8 +6,8 @@ public class Stud extends CardGame implements Gamble, Game {
6 6
     Console console;
7 7
     // private int roundCount = 0;
8 8
 
9
-    public Stud(int minBet, int maxBet, int ante) {
10
-        super(minBet, maxBet, ante);
9
+    public Stud(int ante) {
10
+        super(ante);
11 11
     }
12 12
     
13 13
     public void playCard(Player player, Card card) {
@@ -189,11 +189,9 @@ public class Stud extends CardGame implements Gamble, Game {
189 189
      * Plays through rounds that includes flipping cards face up and then betting or folding
190 190
      */
191 191
     public void gameRound1(){
192
-        for (int j = 0; j < getPlayers().size(); j++) {
193
-            CardPlayer player = super.getPlayers().get(j);                       //GET a player
194
-            playCard(player.getPlayer(), player.getHand().get(0));      //SHOW-PRINT players first CARD
195
-            //roundCount++;
196
-        }
192
+
193
+        playersPlayCard();
194
+
197 195
         for (int x = 0; x < getPlayers().size(); x++) {                          //Betting round or fold
198 196
             CardPlayer player = super.getPlayers().get(x);
199 197
             int bet;
@@ -212,6 +210,14 @@ public class Stud extends CardGame implements Gamble, Game {
212 210
         }
213 211
     }
214 212
 
213
+    public void playersPlayCard(){
214
+        for (int j = 0; j < getPlayers().size(); j++) {
215
+            CardPlayer player = super.getPlayers().get(j);                       //GET a player
216
+            playCard(player.getPlayer(), player.getHand().get(0));      //SHOW-PRINT players first CARD
217
+            //roundCount++;
218
+        }
219
+    }
220
+
215 221
     public void quit() {}
216 222
 
217 223
     /**

+ 12
- 5
src/main/java/io/zipcoder/casino/War.java Visa fil

@@ -14,8 +14,8 @@ public class War extends CardGame implements Gamble, Game {
14 14
     private Scanner scanner = new Scanner(System.in);
15 15
     private boolean war = false;
16 16
 
17
-    War(int minBet, int maxBet, int ante) {
18
-        super(minBet, maxBet, ante);
17
+    War(int ante) {
18
+        super(ante);
19 19
     }
20 20
 
21 21
 
@@ -151,9 +151,9 @@ public class War extends CardGame implements Gamble, Game {
151 151
 
152 152
     public void startRound() {
153 153
         while(super.getLoser() == null) {
154
-            System.out.println("Type play to play the top card from your pile.");
155
-            String input = scanner.next();
156
-            input = input.toLowerCase().trim();
154
+
155
+            String input = getCommand();
156
+
157 157
             if (input.equals("play")) {
158 158
                 //each player
159 159
                 for (CardPlayer player : super.getPlayers()) {
@@ -178,6 +178,13 @@ public class War extends CardGame implements Gamble, Game {
178 178
 
179 179
     }
180 180
 
181
+    public String getCommand(){
182
+        System.out.println("Type play to play the top card from your pile.");
183
+        String input = scanner.next();
184
+        input = input.toLowerCase().trim();
185
+        return input;
186
+    }
187
+
181 188
     public void deal() {
182 189
         //while there are cards in the deck
183 190
         while(super.getDeck().size() != 0){

+ 12
- 0
src/test/java/io/zipcoder/casino/WarTest.java Visa fil

@@ -0,0 +1,12 @@
1
+package io.zipcoder.casino;
2
+
3
+import org.junit.Test;
4
+
5
+public class WarTest {
6
+
7
+    @Test
8
+    public void warTest01(){
9
+
10
+    }
11
+
12
+}