Pārlūkot izejas kodu

refactored packages, sorry

NedRedmond 6 gadus atpakaļ
vecāks
revīzija
aa9ebb1660

+ 4
- 9
src/main/java/io/zipcoder/casino/cardgames/BlackJack.java Parādīt failu

1
 package io.zipcoder.casino.cardgames;
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
 import io.zipcoder.casino.utilities.Console;
6
 import io.zipcoder.casino.utilities.Console;
8
 import io.zipcoder.casino.utilities.Gamble;
7
 import io.zipcoder.casino.utilities.Gamble;
9
 import io.zipcoder.casino.player.BlackJackPlayer;
8
 import io.zipcoder.casino.player.BlackJackPlayer;
10
 import io.zipcoder.casino.player.Player;
9
 import io.zipcoder.casino.player.Player;
11
 import io.zipcoder.casino.player.Players;
10
 import io.zipcoder.casino.player.Players;
12
 
11
 
13
-import java.sql.SQLOutput;
14
 import java.util.ArrayList;
12
 import java.util.ArrayList;
15
-import java.util.Vector;
16
 
13
 
17
 public class BlackJack extends CardGame implements Gamble {
14
 public class BlackJack extends CardGame implements Gamble {
18
 
15
 
25
     public BlackJack(){
22
     public BlackJack(){
26
         readyPlayers();
23
         readyPlayers();
27
         dealCards(2);
24
         dealCards(2);
28
-        for (BlackJackPlayer p : blackJackPlayers) {
29
-          run();
30
-        }
25
+        run();
31
     }
26
     }
32
 
27
 
33
     public void readyPlayers() {
28
     public void readyPlayers() {

+ 1
- 2
src/main/java/io/zipcoder/casino/cardgames/CardGame.java Parādīt failu

1
 package io.zipcoder.casino.cardgames;
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
 import io.zipcoder.casino.utilities.Game;
4
 import io.zipcoder.casino.utilities.Game;
6
 import io.zipcoder.casino.player.Player;
5
 import io.zipcoder.casino.player.Player;
7
 
6
 

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

1
 package io.zipcoder.casino.cardgames;
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
 import io.zipcoder.casino.player.GoFishPlayer;
4
 import io.zipcoder.casino.player.GoFishPlayer;
5
 import io.zipcoder.casino.player.Player;
5
 import io.zipcoder.casino.player.Player;
6
 import io.zipcoder.casino.player.Players;
6
 import io.zipcoder.casino.player.Players;

+ 0
- 53
src/main/java/io/zipcoder/casino/cardgames/cards/Deck.java Parādīt failu

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 Parādīt failu

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

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

1
 package io.zipcoder.casino.player;
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
 public class BlackJackPlayer{
5
 public class BlackJackPlayer{
6
     private CardHand hand;
6
     private CardHand hand;

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

1
 package io.zipcoder.casino.player;
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
 public class GoFishPlayer {
5
 public class GoFishPlayer {
6
     private CardHand hand;
6
     private CardHand hand;

src/main/java/io/zipcoder/casino/cardgames/cards/Card.java → src/main/java/io/zipcoder/casino/utilities/Card.java Parādīt failu

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
 public final class Card {
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 Parādīt failu

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

+ 4
- 10
src/main/java/io/zipcoder/casino/utilities/Game.java Parādīt failu

1
 package io.zipcoder.casino.utilities;
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 Parādīt failu

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
 import java.util.ArrayList;
5
 import java.util.ArrayList;
6
 
6
 

+ 24
- 0
src/main/java/io/zipcoder/casino/utilities/containers/Deck.java Parādīt failu

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 Parādīt failu

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

src/main/java/io/zipcoder/casino/cardgames/cards/CardValue.java → src/main/java/io/zipcoder/casino/utilities/enums/CardValue.java Parādīt failu

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

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

1
 package io.zipcoder.casino;
1
 package io.zipcoder.casino;
2
 
2
 
3
 
3
 
4
+import io.zipcoder.casino.utilities.Dice;
5
+import org.junit.Test;
6
+
4
 public class CasinoTest {
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
 }