Jonathan Hinds 6 lat temu
rodzic
commit
0d66fd62ff

+ 6
- 1
src/main/java/io/zipcoder/casino/CardGame.java Wyświetl plik

@@ -10,7 +10,7 @@ public abstract class CardGame {
10 10
     private int maxBet;
11 11
     private int handSize;
12 12
     private Player playersTurn;
13
-    private Player[] players;
13
+    private ArrayList<CardPlayer> players;
14 14
     private ArrayList<Card> deck = new ArrayList<>();
15 15
 
16 16
 
@@ -39,4 +39,9 @@ public abstract class CardGame {
39 39
     public ArrayList<Card> getDeck() {
40 40
         return deck;
41 41
     }
42
+
43
+    public ArrayList<CardPlayer> getPlayers() {
44
+        return players;
45
+    }
46
+
42 47
 }

+ 4
- 0
src/main/java/io/zipcoder/casino/CardPlayer.java Wyświetl plik

@@ -6,4 +6,8 @@ public class CardPlayer {
6 6
     private Player player;
7 7
     private ArrayList<Card> hand = new ArrayList<>();
8 8
     private ArrayList<Card> discard = new ArrayList<>();
9
+
10
+    public ArrayList<Card> getHand(){
11
+        return hand;
12
+    }
9 13
 }

+ 1
- 2
src/main/java/io/zipcoder/casino/Dice.java Wyświetl plik

@@ -5,8 +5,7 @@ public class Dice {
5 5
 
6 6
     public void roll(){
7 7
 
8
-        //Generate a random number between 1 and 6
9
-        //set value equal to this number
8
+
10 9
 
11 10
     }
12 11
 

+ 13
- 6
src/main/java/io/zipcoder/casino/War.java Wyświetl plik

@@ -59,11 +59,18 @@ public class War extends CardGame implements Gamble, Game {
59 59
     }
60 60
 
61 61
     public void Deal() {
62
-
63
-        /*
64
-            for every player playing this game (i)
65
-                for every card in the deck (j)
66
-
67
-         */
62
+        //while there are cards in the deck
63
+        while(super.getDeck().size() != 0){
64
+            //for each player playing the game
65
+            for(int i = 0; i < super.getPlayers().size(); i ++)
66
+            {
67
+                //grab the card from the top (last added) to the deck
68
+                Card card = super.getDeck().get(super.getDeck().size() - 1);
69
+                //get the player whos hand we are adding the card to
70
+                CardPlayer player = super.getPlayers().get(i);
71
+                //add the card to their hand
72
+                player.getHand().add(card);
73
+            }
74
+        }
68 75
     }
69 76
 }