瀏覽代碼

Merge branch 'Working' of jaejoson/ZCW-OOP-Casino into Working

nedredmond 6 年之前
父節點
當前提交
909756add9

+ 1
- 0
.gitignore 查看文件

@@ -1,3 +1,4 @@
1
+.DS_Store
1 2
 .metadata
2 3
 bin/
3 4
 tmp/

+ 57
- 18
src/main/java/io/zipcoder/casino/cardgames/GoFish.java 查看文件

@@ -1,5 +1,6 @@
1 1
 package io.zipcoder.casino.cardgames;
2 2
 
3
+import io.zipcoder.casino.cardgames.cards.Deck;
3 4
 import io.zipcoder.casino.player.GoFishPlayer;
4 5
 import io.zipcoder.casino.player.Player;
5 6
 import io.zipcoder.casino.player.Players;
@@ -7,11 +8,17 @@ import io.zipcoder.casino.player.Players;
7 8
 import java.util.ArrayList;
8 9
 
9 10
 public class GoFish extends CardGame {
10
-
11
+    private static Deck drawPile = new Deck();
12
+    // Change Deck to deque;
11 13
     private ArrayList<GoFishPlayer> goFishPlayers = new ArrayList<>();
12 14
 
13
-    public GoFish(){
15
+    public static void main(String[] args) {
16
+        System.out.println();
17
+    }
18
+
19
+    public GoFish() {
14 20
         readyPlayers();
21
+        runGame();
15 22
     }
16 23
 
17 24
     public void readyPlayers() {
@@ -20,30 +27,62 @@ public class GoFish extends CardGame {
20 27
         }
21 28
     }
22 29
 
23
-    int setsCount;
30
+    public int getNumberOfCards() {      //generate numberOfCards param for below based on number of players
31
+        int numberOfCards;
32
+        if (goFishPlayers.size() <= 3) {  //RULES: For 3 players or less, deal each player 7 cards;
33
+            numberOfCards = 7;
34
+        } else {                           //RULES contd: if more than three players, deal 5 cards each.
35
+            numberOfCards = 5;
36
+        }
37
+        return numberOfCards;
38
+    }
24 39
 
25 40
     @Override
26 41
     void dealCards(Player player, int numberOfCards) {
27 42
         super.dealCards(player, numberOfCards);
28
-        //For 2 to 3 players you deal each player 7 cards.
29
-        //If there are more than three players, deal 5 cards each.
43
+        // dealPile = dealPile - numberOfCards;
30 44
     }
31 45
 
32
-    public void questionPlayer(String cardRank, Player player) {
33
-        //player surrenders cards of specified rank
34
-    }
46
+    //
47
+    public void updateDrawPile() {
35 48
 
36
-    public void evalCards() {
37
-        //for cards in dealerHand:
38
-//        swap cards or go fish
39
-    }
49
+//    public void play() {
50
+//        for (int i = 0; i }
40 51
 
41
-    public void goFish() {
42
-        //pull from top of deck
43
-    }
52
+//    int setsCount;
44 53
 
45
-    public void checkSets() {
46
-        // check if 4 in dealerHand have same value
47
-    }
48 54
 
55
+        //while (drawPile > 0) {
56
+        //public void questionPlayer(String cardRank, Player player) {
57
+        //start w/ player
58
+        //for (deck.size aka (52 cards - numOfCards per player))
59
+        //askPlayerQuestion(); Prompt w/ question of who to ask [console output?]
60
+        //take userInput [console input?]
61
+        //askPlayerCard(); Prompt w/question of what card (rank) to look for [console output?]
62
+        //take userInput[console input?]
63
+        //for cardHand(chosen player)
64
+        //evalCards(userInput): If userInput.equals(card[i].cardGetValue)
65
+        //swap();
66
+        //repeat until userInput != cardGetValue
67
+        //else
68
+        //goFish(); draw a card from Deck - (deck - 1)
69
+        //move to next player;
70
+        //checkSets: run through each cardHand and looks for 4 of a kind;
71
+        //if found, setsCount++;
72
+
73
+
74
+//    public void evalCards() {
75
+//        //for cards in dealerHand:
76
+////        swap cards or go fish
77
+//    }
78
+//
79
+//    public void goFish() {
80
+//        //pull from top of deck
81
+//    }
82
+//
83
+//    public void checkSets() {
84
+//        // check if 4 in dealerHand have same value
85
+//    }
86
+
87
+    }
49 88
 }

+ 30
- 8
src/main/java/io/zipcoder/casino/cardgames/cards/CardHand.java 查看文件

@@ -1,14 +1,36 @@
1 1
 package io.zipcoder.casino.cardgames.cards;
2 2
 
3
-public class CardHand {
3
+import io.zipcoder.casino.utilities.Console;
4 4
 
5
-    int numberOfCards;
6
-    private java.util.ArrayList<Card> cardHand;
5
+import java.util.ArrayList;
7 6
 
8
-    public CardHand(int numberOfCards) {
9
-        this.numberOfCards = numberOfCards;
10
-    }
7
+public class CardHand extends ArrayList<Card> {
8
+
9
+    int numberOfCards = this.size();
10
+//    private java.util.ArrayList<Card> cardHand;
11
+//
12
+//    public CardHand(int numberOfCards) {
13
+//        this.numberOfCards = numberOfCards;
14
+//    }
15
+//
16
+//    public CardHand() {
17
+//
18
+//    }
19
+
20
+//    public void addCard(Card card) {
21
+//        add(card);
22
+//    }
23
+//
24
+//    public void removeCard(Card card) {
25
+//        remove(card);
26
+//
27
+//    }
11 28
 
12
-    public CardHand() {
29
+    public String display() {
30
+        String result = "";
31
+        for (Card each : this)
32
+            result = each.getCardValue() + " of " + each.getSuit();
33
+        Console.println(result);
34
+        return result;
13 35
     }
14
-}
36
+}

+ 14
- 8
src/main/java/io/zipcoder/casino/cardgames/cards/Deck.java 查看文件

@@ -1,29 +1,33 @@
1 1
 package io.zipcoder.casino.cardgames.cards;
2 2
 
3
-import java.util.ArrayList;
3
+import io.zipcoder.casino.utilities.Console;
4 4
 
5
-public class Deck {
5
+import java.util.ArrayDeque;
6
+import java.util.ArrayList;
7
+import java.util.Deque;
6 8
 
7
-    private ArrayList<Card> deck;
9
+public class Deck extends ArrayDeque<Card> {
10
+    // private ArrayList<Card> deck;
8 11
 
9 12
     public Deck(){
10
-        this.deck = new ArrayList();
13
+        // this.deck = new ArrayList();
11 14
         for (int i = 0; i < 13; i++){
12 15
             CardValue value = CardValue.values()[i];
13 16
 
14 17
             for (int j =0; j < 4;j++){
15 18
                 Card card = new Card (value, CardSuit.values()[j]);
16
-                this.deck.add(card);
19
+                addFirst(card);
17 20
             }
18 21
         }
19 22
 
20 23
 //        Collections.shuffle(deck);
21 24
 
22
-        for (Card aCard : deck) {
25
+        for (Card aCard : this) {
23 26
             Card oneCard = aCard;
24 27
 
25
-            System.out.println(oneCard.getCardValue() + " of " + oneCard.getSuit());
28
+            Console.println(oneCard.getCardValue() + " of " + oneCard.getSuit());
26 29
 //            CardValue.values();
30
+
27 31
         }
28 32
     }
29 33
 
@@ -33,7 +37,9 @@ public class Deck {
33 37
 //            System.out.println(value.getCardValue());
34 38
 //        }
35 39
         Deck deck = new Deck();
36
-        for (Card card : deck.deck) {
40
+        int cardCount = 0;
41
+        for (Card card : deck) {
42
+            cardCount++;
37 43
 //            System.out.println(card.getCardValue() + " " + card.getSuit());
38 44
         }
39 45
     }

+ 1
- 0
src/main/java/io/zipcoder/casino/dicegames/DiceGame.java 查看文件

@@ -4,6 +4,7 @@ import io.zipcoder.casino.dicegames.dice.Dice;
4 4
 import io.zipcoder.casino.utilities.Game;
5 5
 
6 6
 public class DiceGame extends Game {
7
+
7 8
     private Dice dice = new Dice(1);
8 9
 
9 10
     public void rollDie() {

+ 2
- 0
src/main/java/io/zipcoder/casino/dicegames/dice/Dice.java 查看文件

@@ -5,6 +5,8 @@ package io.zipcoder.casino.dicegames.dice;
5 5
     public class Dice {
6 6
         public int dieCount;
7 7
 
8
+//        Dice(){ this.dieCount = 1; }
9
+
8 10
         public Dice(int dieCount) {
9 11
             this.dieCount = dieCount;
10 12
         }