Jonathan Hinds пре 6 година
родитељ
комит
de29fb53db

+ 2
- 0
.gitignore Прегледај датотеку

@@ -9,6 +9,8 @@ local.properties
9 9
 .settings/
10 10
 .loadpath
11 11
 .recommenders
12
+.DS_Store
13
+
12 14
 
13 15
 # External tool builders
14 16
 .externalToolBuilders/


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

@@ -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 Прегледај датотеку

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

+ 13
- 7
src/main/java/io/zipcoder/casino/Stud.java Прегледај датотеку

@@ -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 Прегледај датотеку

@@ -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 Прегледај датотеку

@@ -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
+}