Browse Source

Merge branch 'Working' of https://git.zipcode.rocks/nedredmond/ZCW-OOP-Casino into Working

ThuyKhong 6 years ago
parent
commit
ddf9411916

+ 3
- 6
src/main/java/io/zipcoder/casino/cardgames/BlackJack.java View File

@@ -1,18 +1,15 @@
1 1
 package io.zipcoder.casino.cardgames;
2 2
 
3
-import io.zipcoder.casino.cardgames.cards.Card;
4
-import io.zipcoder.casino.cardgames.cards.CardHand;
5
-import io.zipcoder.casino.cardgames.cards.CardValue;
6
-import io.zipcoder.casino.cardgames.cards.Deck;
3
+import io.zipcoder.casino.utilities.Card;
4
+import io.zipcoder.casino.utilities.containers.CardHand;
5
+import io.zipcoder.casino.utilities.containers.Deck;
7 6
 import io.zipcoder.casino.utilities.Console;
8 7
 import io.zipcoder.casino.utilities.Gamble;
9 8
 import io.zipcoder.casino.player.BlackJackPlayer;
10 9
 import io.zipcoder.casino.player.Player;
11 10
 import io.zipcoder.casino.player.Players;
12 11
 
13
-import java.sql.SQLOutput;
14 12
 import java.util.ArrayList;
15
-import java.util.Vector;
16 13
 
17 14
 public class BlackJack extends CardGame implements Gamble {
18 15
 

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

@@ -1,7 +1,6 @@
1 1
 package io.zipcoder.casino.cardgames;
2 2
 
3
-import io.zipcoder.casino.cardgames.cards.CardHand;
4
-import io.zipcoder.casino.cardgames.cards.Deck;
3
+import io.zipcoder.casino.utilities.containers.Deck;
5 4
 import io.zipcoder.casino.utilities.Game;
6 5
 import io.zipcoder.casino.player.Player;
7 6
 

+ 1
- 1
src/main/java/io/zipcoder/casino/cardgames/GoFish.java View File

@@ -1,6 +1,6 @@
1 1
 package io.zipcoder.casino.cardgames;
2 2
 
3
-import io.zipcoder.casino.cardgames.cards.Deck;
3
+import io.zipcoder.casino.utilities.containers.Deck;
4 4
 import io.zipcoder.casino.player.GoFishPlayer;
5 5
 import io.zipcoder.casino.player.Player;
6 6
 import io.zipcoder.casino.player.Players;

+ 0
- 53
src/main/java/io/zipcoder/casino/cardgames/cards/Deck.java View File

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

+ 1
- 1
src/main/java/io/zipcoder/casino/dicegames/DiceGame.java View File

@@ -1,6 +1,6 @@
1 1
 package io.zipcoder.casino.dicegames;
2 2
 
3
-import io.zipcoder.casino.dicegames.dice.Dice;
3
+import io.zipcoder.casino.utilities.Dice;
4 4
 import io.zipcoder.casino.utilities.Game;
5 5
 
6 6
 public class DiceGame extends Game {

+ 1
- 1
src/main/java/io/zipcoder/casino/player/BlackJackPlayer.java View File

@@ -1,6 +1,6 @@
1 1
 package io.zipcoder.casino.player;
2 2
 
3
-import io.zipcoder.casino.cardgames.cards.CardHand;
3
+import io.zipcoder.casino.utilities.containers.CardHand;
4 4
 
5 5
 public class BlackJackPlayer{
6 6
     private CardHand hand;

+ 1
- 1
src/main/java/io/zipcoder/casino/player/GoFishPlayer.java View File

@@ -1,6 +1,6 @@
1 1
 package io.zipcoder.casino.player;
2 2
 
3
-import io.zipcoder.casino.cardgames.cards.CardHand;
3
+import io.zipcoder.casino.utilities.containers.CardHand;
4 4
 
5 5
 public class GoFishPlayer {
6 6
     private CardHand hand;

src/main/java/io/zipcoder/casino/cardgames/cards/Card.java → src/main/java/io/zipcoder/casino/utilities/Card.java View File

@@ -1,4 +1,7 @@
1
-package io.zipcoder.casino.cardgames.cards;
1
+package io.zipcoder.casino.utilities;
2
+
3
+import io.zipcoder.casino.utilities.enums.CardSuit;
4
+import io.zipcoder.casino.utilities.enums.CardValue;
2 5
 
3 6
 public final class Card {
4 7
 

src/main/java/io/zipcoder/casino/dicegames/dice/Dice.java → src/main/java/io/zipcoder/casino/utilities/Dice.java View File

@@ -1,8 +1,7 @@
1
-package io.zipcoder.casino.dicegames.dice;
1
+package io.zipcoder.casino.utilities;
2 2
 
3 3
     import java.util.ArrayList;
4 4
     import java.util.HashMap;
5
-    import java.util.List;
6 5
     import java.util.Random;
7 6
 
8 7
     public class Dice {
@@ -30,8 +29,6 @@ package io.zipcoder.casino.dicegames.dice;
30 29
             return lastRollGraphic;
31 30
         }
32 31
 
33
-        //        Dice(){ this.dieCount = 1; }
34
-
35 32
         public Dice(int dieCount) {
36 33
             this.dieCount = dieCount;
37 34
         }

+ 4
- 10
src/main/java/io/zipcoder/casino/utilities/Game.java View File

@@ -1,17 +1,11 @@
1 1
 package io.zipcoder.casino.utilities;
2 2
 
3
-public class Game {
4
-    public void promptContinue() {
5
-        // REMATCH (runGame), NEXT GAME (return to casino), EXIT CASINO (quit)
6
-    }
3
+public abstract class Game {
4
+    abstract void promptContinue();
7 5
 
8
-    public void runGame() {
9
-        //initializes game
10
-    }
6
+    abstract void runGame();
11 7
 
12
-    public void endGame() {
13
-        //ends game, returns to Casino prompt loop
14
-    }
8
+    abstract void endGame();
15 9
 
16 10
 
17 11
 }

src/main/java/io/zipcoder/casino/cardgames/cards/CardHand.java → src/main/java/io/zipcoder/casino/utilities/containers/CardHand.java View File

@@ -1,6 +1,6 @@
1
-package io.zipcoder.casino.cardgames.cards;
1
+package io.zipcoder.casino.utilities.containers;
2 2
 
3
-import io.zipcoder.casino.utilities.Console;
3
+import io.zipcoder.casino.utilities.Card;
4 4
 
5 5
 import java.util.ArrayList;
6 6
 

+ 24
- 0
src/main/java/io/zipcoder/casino/utilities/containers/Deck.java View File

@@ -0,0 +1,24 @@
1
+package io.zipcoder.casino.utilities.containers;
2
+
3
+import io.zipcoder.casino.utilities.Card;
4
+import io.zipcoder.casino.utilities.enums.CardSuit;
5
+import io.zipcoder.casino.utilities.enums.CardValue;
6
+
7
+import java.util.ArrayDeque;
8
+import java.util.ArrayList;
9
+import java.util.Collections;
10
+
11
+public class Deck extends ArrayDeque<Card> {
12
+    public Deck(){
13
+        ArrayList<Card> freshDeck = new ArrayList<>();
14
+        for (int i = 0; i < 13; i++){
15
+            CardValue value = CardValue.values()[i];
16
+            for (int j =0; j < 4;j++){
17
+                Card card = new Card (value, CardSuit.values()[j]);
18
+                freshDeck.add(card);
19
+            }
20
+        }
21
+        Collections.shuffle(freshDeck);
22
+        this.addAll(freshDeck);
23
+    }
24
+}

src/main/java/io/zipcoder/casino/cardgames/cards/CardSuit.java → src/main/java/io/zipcoder/casino/utilities/enums/CardSuit.java View File

@@ -1,4 +1,4 @@
1
-package io.zipcoder.casino.cardgames.cards;
1
+package io.zipcoder.casino.utilities.enums;
2 2
 
3 3
 public enum CardSuit {
4 4
     HEARTS('♥'),

src/main/java/io/zipcoder/casino/cardgames/cards/CardValue.java → src/main/java/io/zipcoder/casino/utilities/enums/CardValue.java View File

@@ -1,4 +1,4 @@
1
-package io.zipcoder.casino.cardgames.cards;
1
+package io.zipcoder.casino.utilities.enums;
2 2
 
3 3
 public enum CardValue {
4 4
     ACE(1),

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

@@ -1,5 +1,17 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 
4
+import io.zipcoder.casino.utilities.Dice;
5
+import org.junit.Test;
6
+
4 7
 public class CasinoTest {
8
+
9
+    @Test public void graphicTest() {
10
+        Dice dice = new Dice();
11
+
12
+        for (int i = 1; i <= 6; i++) {
13
+            System.out.println(dice.getDieGraphic(i));
14
+        }
15
+    }
16
+
5 17
 }