Browse Source

updated wartest

Jonathan Hinds 6 years ago
parent
commit
de29fb53db

+ 2
- 0
.gitignore View File

9
 .settings/
9
 .settings/
10
 .loadpath
10
 .loadpath
11
 .recommenders
11
 .recommenders
12
+.DS_Store
13
+
12
 
14
 
13
 # External tool builders
15
 # External tool builders
14
 .externalToolBuilders/
16
 .externalToolBuilders/

BIN
src/.DS_Store View File


+ 1
- 3
src/main/java/io/zipcoder/casino/CardGame.java View File

19
     private Deck deck = new Deck();
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
         this.ante = ante;
23
         this.ante = ante;
26
     }
24
     }
27
 
25
 

+ 2
- 44
src/main/java/io/zipcoder/casino/Console.java View File

44
             switch (command) {
44
             switch (command) {
45
 
45
 
46
                 case "war":
46
                 case "war":
47
-                    int[] warMinMax = getMinMax();
48
-                    Game war = new War(warMinMax[0], warMinMax[1], 10);
47
+                    Game war = new War(10);
49
                     ((War) war).addPlayers(players.get(0));
48
                     ((War) war).addPlayers(players.get(0));
50
                     ((War) war).addNpc();
49
                     ((War) war).addNpc();
51
                     war.startGame();
50
                     war.startGame();
52
                     break;
51
                     break;
53
 
52
 
54
                 case "stud":
53
                 case "stud":
55
-                    int[] studMinMax = getMinMax();
56
-                    Game stud = new Stud(studMinMax[0], studMinMax[1], 10);
54
+                    Game stud = new Stud( 10);
57
                     ((Stud) stud).addPlayers(players.get(0));
55
                     ((Stud) stud).addPlayers(players.get(0));
58
                     addStudPlayers(stud);
56
                     addStudPlayers(stud);
59
                     stud.startGame();
57
                     stud.startGame();
87
         return -1;
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
     public String getCommand() {
88
     public String getCommand() {
113
         String command = "";
89
         String command = "";
114
         String input = scanner.next();
90
         String input = scanner.next();
124
         return command;
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
     public int getStudPlayers() {
103
     public int getStudPlayers() {
146
         int numOfStudPlayers = 0;
104
         int numOfStudPlayers = 0;
147
 
105
 

+ 13
- 7
src/main/java/io/zipcoder/casino/Stud.java View File

6
     Console console;
6
     Console console;
7
     // private int roundCount = 0;
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
     public void playCard(Player player, Card card) {
13
     public void playCard(Player player, Card card) {
189
      * Plays through rounds that includes flipping cards face up and then betting or folding
189
      * Plays through rounds that includes flipping cards face up and then betting or folding
190
      */
190
      */
191
     public void gameRound1(){
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
         for (int x = 0; x < getPlayers().size(); x++) {                          //Betting round or fold
195
         for (int x = 0; x < getPlayers().size(); x++) {                          //Betting round or fold
198
             CardPlayer player = super.getPlayers().get(x);
196
             CardPlayer player = super.getPlayers().get(x);
199
             int bet;
197
             int bet;
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
     public void quit() {}
221
     public void quit() {}
216
 
222
 
217
     /**
223
     /**

+ 12
- 5
src/main/java/io/zipcoder/casino/War.java View File

14
     private Scanner scanner = new Scanner(System.in);
14
     private Scanner scanner = new Scanner(System.in);
15
     private boolean war = false;
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
 
151
 
152
     public void startRound() {
152
     public void startRound() {
153
         while(super.getLoser() == null) {
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
             if (input.equals("play")) {
157
             if (input.equals("play")) {
158
                 //each player
158
                 //each player
159
                 for (CardPlayer player : super.getPlayers()) {
159
                 for (CardPlayer player : super.getPlayers()) {
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
     public void deal() {
188
     public void deal() {
182
         //while there are cards in the deck
189
         //while there are cards in the deck
183
         while(super.getDeck().size() != 0){
190
         while(super.getDeck().size() != 0){

+ 12
- 0
src/test/java/io/zipcoder/casino/WarTest.java View File

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