ソースを参照

Success the lazy way with Ned

Jacqueline Joson 6 年 前
コミット
b015c52c15

+ 33
- 32
src/main/java/io/zipcoder/casino/cardgames/GoFish.java ファイルの表示

@@ -15,7 +15,8 @@ public class GoFish extends CardGame {
15 15
     public static void main(String[] args) {
16 16
         System.out.println();
17 17
     }
18
-    public GoFish(){
18
+
19
+    public GoFish() {
19 20
         readyPlayers();
20 21
         runGame();
21 22
     }
@@ -41,47 +42,47 @@ public class GoFish extends CardGame {
41 42
         super.dealCards(player, numberOfCards);
42 43
         // dealPile = dealPile - numberOfCards;
43 44
     }
44
-//
45
-    public void updateDrawPile() {
46 45
 
47
-    public void play() {
48
-        for (int i = 0; i }
46
+    //
47
+    public void updateDrawPile() {
49 48
 
50
-    int setsCount;
49
+//    public void play() {
50
+//        for (int i = 0; i }
51 51
 
52
+//    int setsCount;
52 53
 
53 54
 
54
-    //while (drawPile > 0) {
55
-    //public void questionPlayer(String cardRank, Player player) {
55
+        //while (drawPile > 0) {
56
+        //public void questionPlayer(String cardRank, Player player) {
56 57
         //start w/ player
57 58
         //for (deck.size aka (52 cards - numOfCards per player))
58
-            //askPlayerQuestion(); Prompt w/ question of who to ask [console output?]
59
-            //take userInput [console input?]
60
-            //askPlayerCard(); Prompt w/question of what card (rank) to look for [console output?]
61
-            //take userInput[console input?]
62
-                //for cardHand(chosen player)
63
-                    //evalCards(userInput): If userInput.equals(card[i].cardGetValue)
64
-                                                     //swap();
65
-                                                    //repeat until userInput != cardGetValue
66
-                                                    //else
67
-                                                         //goFish(); draw a card from Deck - (deck - 1)
68
-                                                        //move to next 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;
69 70
         //checkSets: run through each cardHand and looks for 4 of a kind;
70
-                //if found, setsCount++;
71
-
71
+        //if found, setsCount++;
72 72
 
73 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
-    }
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
+//    }
82 86
 
83
-    public void checkSets() {
84
-        // check if 4 in dealerHand have same value
85 87
     }
86
-
87 88
 }

+ 14
- 16
src/main/java/io/zipcoder/casino/cardgames/cards/CardHand.java ファイルの表示

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

+ 11
- 8
src/main/java/io/zipcoder/casino/cardgames/cards/Deck.java ファイルの表示

@@ -1,28 +1,31 @@
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();
27 30
 
28 31
         }
@@ -35,7 +38,7 @@ public class Deck {
35 38
 //        }
36 39
         Deck deck = new Deck();
37 40
         int cardCount = 0;
38
-        for (Card card : deck.deck) {
41
+        for (Card card : deck) {
39 42
             cardCount++;
40 43
 //            System.out.println(card.getCardValue() + " " + card.getSuit());
41 44
         }

+ 2
- 1
src/main/java/io/zipcoder/casino/dicegames/dice/Dice.java ファイルの表示

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