Sfoglia il codice sorgente

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

merging current
Connor Dunnigan 6 anni fa
parent
commit
a935eed995
25 ha cambiato i file con 82 aggiunte e 41 eliminazioni
  1. 3
    0
      src/main/java/io/zipcoder/casino/Casino.java
  2. 8
    2
      src/main/java/io/zipcoder/casino/cardgames/BlackJack.java
  3. 6
    1
      src/main/java/io/zipcoder/casino/cardgames/CardGame.java
  4. 6
    2
      src/main/java/io/zipcoder/casino/cardgames/GoFish.java
  5. 1
    1
      src/main/java/io/zipcoder/casino/cardgames/cards/Card.java
  6. 1
    2
      src/main/java/io/zipcoder/casino/cardgames/cards/CardHand.java
  7. 1
    1
      src/main/java/io/zipcoder/casino/cardgames/cards/CardSuit.java
  8. 1
    1
      src/main/java/io/zipcoder/casino/cardgames/cards/CardValue.java
  9. 1
    2
      src/main/java/io/zipcoder/casino/cardgames/cards/Deck.java
  10. 12
    7
      src/main/java/io/zipcoder/casino/dicegames/Craps.java
  11. 4
    1
      src/main/java/io/zipcoder/casino/dicegames/DiceGame.java
  12. 1
    2
      src/main/java/io/zipcoder/casino/dicegames/dice/Dice.java
  13. 6
    2
      src/main/java/io/zipcoder/casino/player/BlackJackPlayer.java
  14. 5
    1
      src/main/java/io/zipcoder/casino/player/CrapsPlayer.java
  15. 7
    1
      src/main/java/io/zipcoder/casino/player/GoFishPlayer.java
  16. 1
    1
      src/main/java/io/zipcoder/casino/player/Player.java
  17. 4
    1
      src/main/java/io/zipcoder/casino/player/Players.java
  18. 1
    1
      src/main/java/io/zipcoder/casino/utilities/Console.java
  19. 3
    1
      src/main/java/io/zipcoder/casino/utilities/Gamble.java
  20. 1
    1
      src/main/java/io/zipcoder/casino/utilities/Game.java
  21. 1
    1
      src/main/java/io/zipcoder/casino/utilities/Pot.java
  22. 2
    2
      src/test/java/io/zipcoder/casino/BlackJackPlayerTest.java
  23. 3
    1
      src/test/java/io/zipcoder/casino/CrapsTest.java
  24. 1
    2
      src/test/java/io/zipcoder/casino/PlayerTest.java
  25. 2
    4
      src/test/java/io/zipcoder/casino/PlayersTest.java

+ 3
- 0
src/main/java/io/zipcoder/casino/Casino.java Vedi File

@@ -1,6 +1,9 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 
4
+import io.zipcoder.casino.player.Players;
5
+import io.zipcoder.casino.utilities.Game;
6
+
4 7
 public class Casino {
5 8
     private Game game;
6 9
 

src/main/java/io/zipcoder/casino/BlackJack.java → src/main/java/io/zipcoder/casino/cardgames/BlackJack.java Vedi File

@@ -1,4 +1,10 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.cardgames;
2
+
3
+import io.zipcoder.casino.cardgames.cards.Deck;
4
+import io.zipcoder.casino.utilities.Gamble;
5
+import io.zipcoder.casino.player.BlackJackPlayer;
6
+import io.zipcoder.casino.player.Player;
7
+import io.zipcoder.casino.player.Players;
2 8
 
3 9
 import java.util.ArrayList;
4 10
 
@@ -11,7 +17,7 @@ public class BlackJack extends CardGame implements Gamble {
11 17
     }
12 18
 
13 19
     public void readyPlayers() {
14
-        for (Player player : Players.getInstance().playerList) {
20
+        for (Player player : Players.getInstance().getPlayers()) {
15 21
             blackJackPlayers.add(new BlackJackPlayer(player));
16 22
         }
17 23
     }

src/main/java/io/zipcoder/casino/CardGame.java → src/main/java/io/zipcoder/casino/cardgames/CardGame.java Vedi File

@@ -1,4 +1,9 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.cardgames;
2
+
3
+import io.zipcoder.casino.cardgames.cards.CardHand;
4
+import io.zipcoder.casino.cardgames.cards.Deck;
5
+import io.zipcoder.casino.utilities.Game;
6
+import io.zipcoder.casino.player.Player;
2 7
 
3 8
 public class CardGame extends Game {
4 9
 

src/main/java/io/zipcoder/casino/GoFish.java → src/main/java/io/zipcoder/casino/cardgames/GoFish.java Vedi File

@@ -1,4 +1,8 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.cardgames;
2
+
3
+import io.zipcoder.casino.player.GoFishPlayer;
4
+import io.zipcoder.casino.player.Player;
5
+import io.zipcoder.casino.player.Players;
2 6
 
3 7
 import java.util.ArrayList;
4 8
 
@@ -11,7 +15,7 @@ public class GoFish extends CardGame {
11 15
     }
12 16
 
13 17
     public void readyPlayers() {
14
-        for (Player player : Players.getInstance().playerList) {
18
+        for (Player player : Players.getInstance().getPlayers()) {
15 19
             goFishPlayers.add(new GoFishPlayer(player));
16 20
         }
17 21
     }

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

@@ -1,4 +1,4 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.cardgames.cards;
2 2
 
3 3
 public final class Card {
4 4
 

src/main/java/io/zipcoder/casino/CardHand.java → src/main/java/io/zipcoder/casino/cardgames/cards/CardHand.java Vedi File

@@ -1,4 +1,4 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.cardgames.cards;
2 2
 
3 3
 public class CardHand {
4 4
 
@@ -9,7 +9,6 @@ public class CardHand {
9 9
         this.numberOfCards = numberOfCards;
10 10
     }
11 11
 
12
-
13 12
     public CardHand() {
14 13
     }
15 14
 }

src/main/java/io/zipcoder/casino/CardSuit.java → src/main/java/io/zipcoder/casino/cardgames/cards/CardSuit.java Vedi File

@@ -1,4 +1,4 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.cardgames.cards;
2 2
 
3 3
 public enum CardSuit {
4 4
     HEARTS,

src/main/java/io/zipcoder/casino/CardValue.java → src/main/java/io/zipcoder/casino/cardgames/cards/CardValue.java Vedi File

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

src/main/java/io/zipcoder/casino/Deck.java → src/main/java/io/zipcoder/casino/cardgames/cards/Deck.java Vedi File

@@ -1,7 +1,6 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.cardgames.cards;
2 2
 
3 3
 import java.util.ArrayList;
4
-import java.util.Collections;
5 4
 
6 5
 public class Deck {
7 6
 

src/main/java/io/zipcoder/casino/Craps.java → src/main/java/io/zipcoder/casino/dicegames/Craps.java Vedi File

@@ -1,4 +1,9 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.dicegames;
2
+
3
+import io.zipcoder.casino.utilities.Gamble;
4
+import io.zipcoder.casino.player.CrapsPlayer;
5
+import io.zipcoder.casino.player.Player;
6
+import io.zipcoder.casino.player.Players;
2 7
 
3 8
 import java.util.ArrayList;
4 9
 
@@ -19,7 +24,7 @@ public class Craps extends DiceGame implements Gamble {
19 24
     }
20 25
 
21 26
     public void readyPlayers() {
22
-        for (Player player : Players.getInstance().playerList) {
27
+        for (Player player : Players.getInstance().getPlayers()) {
23 28
             crapsPlayers.add(new CrapsPlayer(player));
24 29
         }
25 30
     }
@@ -45,17 +50,17 @@ public class Craps extends DiceGame implements Gamble {
45 50
         int sum = rollDie(2); // roll two dice, store sum in sum field.
46 51
 
47 52
         if (sum == 7 || sum == 11) {
48
-            evaluateBet(currentPlayer.crapsPlayer, bet*2);
53
+            evaluateBet(currentPlayer.getP(), bet*2);
49 54
         } else if (sum == 2 || sum == 3 || sum == 12) {
50
-            evaluateBet(currentPlayer.crapsPlayer, -(bet*2));
55
+            evaluateBet(currentPlayer.getP(), -(bet*2));
51 56
         } else {
52 57
             int point = sum;
53 58
             do {
54 59
                 sum = rollDie(2);
55 60
                 if (sum == 7) {
56
-                    evaluateBet(currentPlayer.crapsPlayer, -bet);
61
+                    evaluateBet(currentPlayer.getP(), -bet);
57 62
                 } else if (sum == point) {
58
-                    evaluateBet(currentPlayer.crapsPlayer, bet);
63
+                    evaluateBet(currentPlayer.getP(), bet);
59 64
                 }
60 65
             } while (sum != point && sum != 7);
61 66
         }
@@ -63,7 +68,7 @@ public class Craps extends DiceGame implements Gamble {
63 68
 
64 69
     public void print(){
65 70
         for(int i = 0; i < crapsPlayers.size(); i++){
66
-            System.out.println(crapsPlayers.get(i).crapsPlayer.getChipBalance());
71
+            System.out.println(crapsPlayers.get(i).getP().getChipBalance());
67 72
         }
68 73
     }
69 74
 }

src/main/java/io/zipcoder/casino/DiceGame.java → src/main/java/io/zipcoder/casino/dicegames/DiceGame.java Vedi File

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

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

@@ -1,11 +1,10 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.dicegames.dice;
2 2
 
3 3
     import java.util.Random;
4 4
 
5 5
     public class Dice {
6 6
         public int dieCount;
7 7
 
8
-        Dice(){ this.dieCount = 1; }
9 8
         Dice(int dieCount) {
10 9
             this.dieCount = dieCount;
11 10
         }

src/main/java/io/zipcoder/casino/BlackJackPlayer.java → src/main/java/io/zipcoder/casino/player/BlackJackPlayer.java Vedi File

@@ -1,6 +1,6 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.player;
2 2
 
3
-import java.util.ArrayList;
3
+import io.zipcoder.casino.cardgames.cards.CardHand;
4 4
 
5 5
 public class BlackJackPlayer {
6 6
     private CardHand hand;
@@ -17,6 +17,10 @@ public class BlackJackPlayer {
17 17
     public void stay(Player player) {
18 18
     }
19 19
 
20
+    public Player getP() {
21
+        return blackJackPlayer;
22
+    }
23
+
20 24
     public CardHand getHand() {
21 25
         return hand;
22 26
     }

src/main/java/io/zipcoder/casino/CrapsPlayer.java → src/main/java/io/zipcoder/casino/player/CrapsPlayer.java Vedi File

@@ -1,4 +1,4 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.player;
2 2
 
3 3
 public class CrapsPlayer {
4 4
     Player crapsPlayer;
@@ -13,6 +13,10 @@ public class CrapsPlayer {
13 13
         this.bet = bet;
14 14
     }
15 15
 
16
+    public Player getP() {
17
+        return crapsPlayer;
18
+    }
19
+
16 20
     public long getBet() {
17 21
         return bet;
18 22
     }

src/main/java/io/zipcoder/casino/GoFishPlayer.java → src/main/java/io/zipcoder/casino/player/GoFishPlayer.java Vedi File

@@ -1,4 +1,6 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.player;
2
+
3
+import io.zipcoder.casino.cardgames.cards.CardHand;
2 4
 
3 5
 public class GoFishPlayer {
4 6
     private CardHand hand;
@@ -9,6 +11,10 @@ public class GoFishPlayer {
9 11
         this.goFishPlayer = player;
10 12
     }
11 13
 
14
+    public Player getP() {
15
+        return goFishPlayer;
16
+    }
17
+
12 18
     public CardHand getHand() {
13 19
         return hand;
14 20
     }

src/main/java/io/zipcoder/casino/Player.java → src/main/java/io/zipcoder/casino/player/Player.java Vedi File

@@ -1,4 +1,4 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.player;
2 2
 
3 3
 public class Player {
4 4
 

src/main/java/io/zipcoder/casino/Players.java → src/main/java/io/zipcoder/casino/player/Players.java Vedi File

@@ -1,4 +1,4 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.player;
2 2
 
3 3
 import java.util.ArrayList;
4 4
 
@@ -29,6 +29,9 @@ public class Players {
29 29
         }
30 30
     }
31 31
 
32
+    public ArrayList<Player> getPlayers() {
33
+        return playerList;
34
+    }
32 35
 
33 36
     public void removePlayer(final Player player) {
34 37
         playerList.removeIf(Player -> Player.equals(player));

src/main/java/io/zipcoder/casino/Console.java → src/main/java/io/zipcoder/casino/utilities/Console.java Vedi File

@@ -1,4 +1,4 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.utilities;
2 2
 
3 3
 import java.awt.peer.SystemTrayPeer;
4 4
 import java.util.Scanner;

src/main/java/io/zipcoder/casino/Gamble.java → src/main/java/io/zipcoder/casino/utilities/Gamble.java Vedi File

@@ -1,4 +1,6 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.utilities;
2
+
3
+import io.zipcoder.casino.player.Player;
2 4
 
3 5
 public interface Gamble {
4 6
     public void placeBet();

src/main/java/io/zipcoder/casino/Game.java → src/main/java/io/zipcoder/casino/utilities/Game.java Vedi File

@@ -1,4 +1,4 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.utilities;
2 2
 
3 3
 public class Game {
4 4
     public void promptContinue() {

src/main/java/io/zipcoder/casino/Pot.java → src/main/java/io/zipcoder/casino/utilities/Pot.java Vedi File

@@ -1,4 +1,4 @@
1
-package io.zipcoder.casino;
1
+package io.zipcoder.casino.utilities;
2 2
 
3 3
 public class Pot {
4 4
 

+ 2
- 2
src/test/java/io/zipcoder/casino/BlackJackPlayerTest.java Vedi File

@@ -1,10 +1,10 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
+import io.zipcoder.casino.player.BlackJackPlayer;
4
+import io.zipcoder.casino.player.Player;
3 5
 import org.junit.Before;
4 6
 import org.junit.Test;
5 7
 
6
-import static org.junit.Assert.*;
7
-
8 8
 public class BlackJackPlayerTest {
9 9
     Player player = new Player("Mr. Guy");
10 10
 

+ 3
- 1
src/test/java/io/zipcoder/casino/CrapsTest.java Vedi File

@@ -1,7 +1,9 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
+import io.zipcoder.casino.dicegames.Craps;
4
+import io.zipcoder.casino.player.CrapsPlayer;
5
+import io.zipcoder.casino.player.Player;
3 6
 import org.junit.Test;
4
-import org.junit.Assert;
5 7
 
6 8
 import java.util.*;
7 9
 

+ 1
- 2
src/test/java/io/zipcoder/casino/PlayerTest.java Vedi File

@@ -1,11 +1,10 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
+import io.zipcoder.casino.player.Player;
3 4
 import org.junit.Assert;
4 5
 import org.junit.Before;
5 6
 import org.junit.Test;
6 7
 
7
-import static org.junit.Assert.*;
8
-
9 8
 public class PlayerTest {
10 9
 
11 10
     Player player;

+ 2
- 4
src/test/java/io/zipcoder/casino/PlayersTest.java Vedi File

@@ -1,13 +1,11 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
+import io.zipcoder.casino.player.Player;
4
+import io.zipcoder.casino.player.Players;
3 5
 import org.junit.Assert;
4 6
 import org.junit.Before;
5 7
 import org.junit.Test;
6 8
 
7
-import java.util.ArrayList;
8
-
9
-import static org.junit.Assert.*;
10
-
11 9
 public class PlayersTest {
12 10
 
13 11
     Player player1 = new Player("Bobbert");