Przeglądaj źródła

UML donegit statusgit status! except craps

Jennifer Chao 6 lat temu
rodzic
commit
110460a4b3

+ 72
- 0
src/main/java/io/zipcoder/casino/BlackJack.java Wyświetl plik

@@ -0,0 +1,72 @@
1
+package io.zipcoder.casino;
2
+
3
+import java.util.ArrayList;
4
+
5
+public class BlackJack extends CardGame implements Gamble {
6
+
7
+    private ArrayList<BlackJackPlayer> blackJackPlayers;
8
+    private int minBet;
9
+    private ArrayList<Card> wastepile;
10
+    private java.util.ArrayList<Card> dealerHand;
11
+
12
+    public BlackJack(Player player) {
13
+        BlackJackPlayer blackJackPlayer = new BlackJackPlayer(player);
14
+        this.blackJackPlayers.add(blackJackPlayer);
15
+    }
16
+
17
+    // basically draw
18
+    public Card hit() {
19
+        return null;
20
+    }
21
+
22
+    public void flip() {
23
+        // shoulder technically be card.setCovered(false); or something like that
24
+        boolean covered = false;
25
+    }
26
+
27
+    public void split() {
28
+        // must be the same card value
29
+    }
30
+
31
+    public void doubleDown() {
32
+        // must be right after the first daeling
33
+    }
34
+
35
+    public void stand() {
36
+    }
37
+
38
+    public int countHand() {
39
+        return 0;
40
+    }
41
+
42
+    public void deal() {
43
+    }
44
+
45
+    public void start() {
46
+
47
+    }
48
+
49
+    public void end() {
50
+
51
+    }
52
+
53
+    public void takeATurn() {
54
+
55
+    }
56
+
57
+    public void addPlayer() {
58
+
59
+    }
60
+
61
+    public void removePlayer() {
62
+
63
+    }
64
+
65
+    public int betAmount(int amount, Player player) {
66
+        return 0;
67
+    }
68
+
69
+    public void distributePot(int amount, Player player) {
70
+
71
+    }
72
+}

+ 16
- 0
src/main/java/io/zipcoder/casino/BlackJackPlayer.java Wyświetl plik

@@ -0,0 +1,16 @@
1
+package io.zipcoder.casino;
2
+
3
+public class BlackJackPlayer {
4
+
5
+    private Player player;
6
+
7
+    private int initialBet;
8
+    private int handValue;
9
+    private java.util.ArrayList<Card> playerHand;
10
+    private int betPot;
11
+
12
+    public BlackJackPlayer(Player player) {
13
+        this.player = player;
14
+    }
15
+
16
+}

+ 16
- 0
src/main/java/io/zipcoder/casino/Card.java Wyświetl plik

@@ -0,0 +1,16 @@
1
+package io.zipcoder.casino;
2
+
3
+public class Card {
4
+
5
+    private String suit;
6
+    private String color;
7
+    private String face;
8
+    private boolean covered;
9
+
10
+    public Card drawCard() {
11
+        return null;
12
+    }
13
+
14
+    public void shuffleDeck() {
15
+    }
16
+}

+ 14
- 0
src/main/java/io/zipcoder/casino/CardGame.java Wyświetl plik

@@ -0,0 +1,14 @@
1
+package io.zipcoder.casino;
2
+
3
+import java.util.ArrayList;
4
+
5
+public abstract class CardGame implements Game {
6
+
7
+    private Deck deck;
8
+
9
+//    public abstract Card draw();
10
+//
11
+//    public abstract void flip();
12
+
13
+
14
+}

+ 38
- 0
src/main/java/io/zipcoder/casino/Casino.java Wyświetl plik

@@ -1,5 +1,43 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
+// BlackJack
4
+// Solitaire
5
+// Craps
6
+// Roulette?
7
+// Slot Machine?
8
+
9
+// Jackpot option? Low chance but player wins $1mil
3 10
 
4 11
 public class Casino {
12
+
13
+    private int money;
14
+    private String casinoName;
15
+    private Game game;
16
+    private Player player;
17
+    private String currentGame;
18
+
19
+    public void selectGame(int gameNum) {
20
+
21
+        switch (gameNum) {
22
+            case 1:
23
+                Game blackJack = new BlackJack(player);
24
+                break;
25
+            case 2:
26
+                Game solitaire = new Solitaire(player);
27
+                break;
28
+            case 3:
29
+                Game craps = new Craps(player);
30
+                break;
31
+            case 4:
32
+                leaveCasino();
33
+                break;
34
+            default:
35
+                System.out.println("Input unknown, please pick again.");
36
+                break;
37
+        }
38
+    }
39
+
40
+    public void leaveCasino() {
41
+    }
42
+
5 43
 }

+ 19
- 0
src/main/java/io/zipcoder/casino/Craps.java Wyświetl plik

@@ -0,0 +1,19 @@
1
+package io.zipcoder.casino;
2
+
3
+import java.util.Map;
4
+
5
+public class Craps extends DiceGame implements Gamble {
6
+
7
+    private Player player;
8
+    private int hold;
9
+    private Map<Integer, Integer> betPots;
10
+
11
+    public Craps(Player player) {
12
+        this.player = player;
13
+    }
14
+
15
+    public int rollDice() {
16
+        return 0;
17
+    }
18
+
19
+}

+ 10
- 0
src/main/java/io/zipcoder/casino/Deck.java Wyświetl plik

@@ -0,0 +1,10 @@
1
+package io.zipcoder.casino;
2
+
3
+public class Deck {
4
+
5
+        private Card[] deckOfCards = new Card[52];
6
+        // needs 1-13 of each suit
7
+        // assign each index to a specific card,
8
+        // e.g. 0-12 = spades; 13-25 = clubs; 26-38 = hearts; 39-51 = diamonds
9
+
10
+}

+ 21
- 0
src/main/java/io/zipcoder/casino/Dice.java Wyświetl plik

@@ -0,0 +1,21 @@
1
+package io.zipcoder.casino;
2
+
3
+public class Dice {
4
+
5
+//    private int[] die;
6
+//    private ArrayList<Dice> dice;
7
+
8
+//    public Dice() {
9
+//        this.die = new int[6];
10
+//    }
11
+//
12
+//    public Dice(int numOfDice) {
13
+//        this.dice = new ArrayList<Dice>(numOfDice);
14
+//    }
15
+
16
+    public int rollDie() {
17
+        return (int) Math.floor((Math.random() * 6) + 1);
18
+    }
19
+
20
+
21
+}

+ 19
- 0
src/main/java/io/zipcoder/casino/DiceGame.java Wyświetl plik

@@ -0,0 +1,19 @@
1
+package io.zipcoder.casino;
2
+
3
+public abstract class DiceGame implements Game {
4
+
5
+    private int numOfDice = 2;
6
+    private int[] die = new int[numOfDice];
7
+
8
+    public int rollDice(int numOfDice) {
9
+        int sum = 0;
10
+
11
+        for (int i = 0; i < numOfDice; i++) {
12
+            die[i] = (int) Math.floor((Math.random() * 6) + 1);
13
+            sum += die[i];
14
+        }
15
+
16
+        return sum;
17
+    }
18
+
19
+}

+ 14
- 0
src/main/java/io/zipcoder/casino/Foundation.java Wyświetl plik

@@ -0,0 +1,14 @@
1
+package io.zipcoder.casino;
2
+
3
+import java.util.Stack;
4
+
5
+public class Foundation {
6
+
7
+    private Stack stack;
8
+
9
+    public Foundation(){
10
+        this.stack = new Stack<Card>();
11
+    }
12
+
13
+
14
+}

+ 7
- 0
src/main/java/io/zipcoder/casino/Gamble.java Wyświetl plik

@@ -0,0 +1,7 @@
1
+package io.zipcoder.casino;
2
+
3
+public interface Gamble {
4
+    int betAmount(int amount, Player player);
5
+
6
+    void distributePot(int amount, Player player);
7
+}

+ 13
- 0
src/main/java/io/zipcoder/casino/Game.java Wyświetl plik

@@ -0,0 +1,13 @@
1
+package io.zipcoder.casino;
2
+
3
+public interface Game {
4
+    void start();
5
+
6
+    void end();
7
+
8
+    void takeATurn();
9
+
10
+    void addPlayer();
11
+
12
+    void removePlayer();
13
+}

+ 6
- 0
src/main/java/io/zipcoder/casino/InputOutput.java Wyświetl plik

@@ -0,0 +1,6 @@
1
+package io.zipcoder.casino;
2
+
3
+public class InputOutput {
4
+
5
+    // multiple users?
6
+}

+ 29
- 0
src/main/java/io/zipcoder/casino/Player.java Wyświetl plik

@@ -0,0 +1,29 @@
1
+package io.zipcoder.casino;
2
+
3
+public class Player {
4
+
5
+    // cashmoney?
6
+    private int wallet;
7
+    private String name;
8
+
9
+    public Player(String name) {
10
+        this.wallet = 500;
11
+        this.name = name;
12
+    }
13
+
14
+    public int getWallet() {
15
+        return wallet;
16
+    }
17
+
18
+    public void setWallet(int wallet) {
19
+        this.wallet = wallet;
20
+    }
21
+
22
+    public String getName() {
23
+        return name;
24
+    }
25
+
26
+    public void setName(String name) {
27
+        this.name = name;
28
+    }
29
+}

+ 30
- 0
src/main/java/io/zipcoder/casino/Solitaire.java Wyświetl plik

@@ -0,0 +1,30 @@
1
+package io.zipcoder.casino;
2
+
3
+public class Solitaire extends CardGame {
4
+
5
+    private Player player;
6
+    private Tableau tableau;
7
+    private Foundation foundation;
8
+    private java.util.Stack wastepile;
9
+
10
+
11
+    public Solitaire(Player player) {
12
+        this.player = player;
13
+    }
14
+
15
+    public void moveable() {
16
+    }
17
+
18
+    public void receivable() {
19
+    }
20
+
21
+    public Card draw() {
22
+        return null;
23
+    }
24
+
25
+    public void flip() {
26
+        // shoulder technically be card.setCovered(false); or something like that
27
+        boolean covered = false;
28
+    }
29
+
30
+}

+ 13
- 0
src/main/java/io/zipcoder/casino/Tableau.java Wyświetl plik

@@ -0,0 +1,13 @@
1
+package io.zipcoder.casino;
2
+
3
+import java.util.Stack;
4
+
5
+public class Tableau {
6
+
7
+    private Stack stack;
8
+
9
+    public Tableau(){
10
+        this.stack = new Stack<Card>();
11
+    }
12
+
13
+}

+ 4
- 0
src/main/java/io/zipcoder/casino/test.java Wyświetl plik

@@ -0,0 +1,4 @@
1
+package io.zipcoder.casino;
2
+
3
+public class test {
4
+}

+ 4
- 0
src/test/java/io/zipcoder/casino/BlackJackTest.java Wyświetl plik

@@ -0,0 +1,4 @@
1
+package io.zipcoder.casino;
2
+
3
+public class BlackJackTest {
4
+}

+ 4
- 0
src/test/java/io/zipcoder/casino/CrapsTest.java Wyświetl plik

@@ -0,0 +1,4 @@
1
+package io.zipcoder.casino;
2
+
3
+public class CrapsTest {
4
+}

+ 4
- 0
src/test/java/io/zipcoder/casino/PlayerTest.java Wyświetl plik

@@ -0,0 +1,4 @@
1
+package io.zipcoder.casino;
2
+
3
+public class PlayerTest {
4
+}

+ 4
- 0
src/test/java/io/zipcoder/casino/SolitaireTest.java Wyświetl plik

@@ -0,0 +1,4 @@
1
+package io.zipcoder.casino;
2
+
3
+public class SolitaireTest {
4
+}