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

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

17
         Printer.printMessage(player.getName() + " shows a " + card.getName());         //PRINT card name to CONSOLE
17
         Printer.printMessage(player.getName() + " shows a " + card.getName());         //PRINT card name to CONSOLE
18
     }
18
     }
19
 
19
 
20
-
21
     public boolean getIsDealt(){
20
     public boolean getIsDealt(){
22
         return isDealt;
21
         return isDealt;
23
     }
22
     }
24
 
23
 
25
-
26
     /**
24
     /**
27
      * Determine what player wins by looping through player array and then
25
      * Determine what player wins by looping through player array and then
28
      * passing each hand to the 'handValue' method
26
      * passing each hand to the 'handValue' method
143
     }
141
     }
144
 
142
 
145
     public void startGame() {
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
      * Deal each player(and dealer) 3 face down cards in turn
177
      * Deal each player(and dealer) 3 face down cards in turn
180
      */
178
      */
181
     public void deal(ArrayList<CardPlayer> players) {
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
         isDealt = true;
185
         isDealt = true;

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

1
 package io.zipcoder.casino;
1
 package io.zipcoder.casino;
2
 
2
 
3
 import java.util.*;
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
 public class War extends CardGame implements Gamble, Game {
5
 public class War extends CardGame implements Gamble, Game {
11
 
6
 
117
 
112
 
118
     public void startGame(){
113
     public void startGame(){
119
         Printer.printMessage("Welcome to War!");
114
         Printer.printMessage("Welcome to War!");
120
-        super.chooseStatingPlayer();
115
+        super.chooseStartingPlayer();
121
         payAnte();
116
         payAnte();
122
         deal();
117
         deal();
123
         startRound();
118
         startRound();

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

37
         boolean after = card.isVisible();
37
         boolean after = card.isVisible();
38
         Assert.assertNotEquals(before, after);
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
         stud.payAnte(players);
246
         stud.payAnte(players);
247
         System.out.println(players.get(0).getPlayer().getCurrentBalance());
247
         System.out.println(players.get(0).getPlayer().getCurrentBalance());
248
         //WHEN @Before
248
         //WHEN @Before
249
-        int expected = 10;
249
+        int expected = 0;
250
         //THEN
250
         //THEN
251
         int actual = players.get(0).getPlayer().getCurrentBalance();
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
         War war = new War(10);
25
         War war = new War(10);
26
         Player player = new Player("Jon", 100);
26
         Player player = new Player("Jon", 100);
27
         war.addPlayers(player);
27
         war.addPlayers(player);
28
-        war.chooseStatingPlayer();
28
+        war.chooseStartingPlayer();
29
         war.deal();
29
         war.deal();
30
         war.getPlayers().get(0).setDiscard(deck);
30
         war.getPlayers().get(0).setDiscard(deck);
31
 
31
 
39
         War war = new War(10);
39
         War war = new War(10);
40
         Player player = new Player("Jon", 100);
40
         Player player = new Player("Jon", 100);
41
         war.addPlayers(player);
41
         war.addPlayers(player);
42
-        war.chooseStatingPlayer();
42
+        war.chooseStartingPlayer();
43
         war.playCard(false);
43
         war.playCard(false);
44
 
44
 
45
         Assert.assertEquals(war.getLoser(), player);
45
         Assert.assertEquals(war.getLoser(), player);