Xcuello 6 vuotta sitten
vanhempi
commit
716bae87f5

+ 0
- 11
src/main/java/io/zipcoder/casino/BlackjackDealer.java Näytä tiedosto

@@ -1,11 +0,0 @@
1
-package io.zipcoder.casino;
2
-
3
-public class BlackjackDealer extends BlackjackPlayer {
4
-    public void dealCards(Player player, Card card){
5
-
6
-    }
7
-
8
-    public void takeBet(Player player, double money){
9
-
10
-    }
11
-}

+ 3
- 21
src/main/java/io/zipcoder/casino/BlackjackPlayer.java Näytä tiedosto

@@ -1,28 +1,10 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
-public class BlackjackPlayer {
3
+public class BlackjackPlayer extends Player{
4 4
 
5
-    private double wager;
6 5
 
7
-    private double money;
8
-
9
-
10
-    public void blackjackPlayer(double money) {
11
-
12
-    }
13
-
14
-    public double setBet(double money) {
15
-
16
-        this.wager = money;
17
-
18
-        return money;
19
-    }
20
-
21
-    public double getBet(double money) {
22
-
23
-        this.wager = money;
24
-
25
-        return money;
6
+    public BlackjackPlayer(String name, double moneyStartedWith) {
26 7
 
8
+        super(name, moneyStartedWith);
27 9
     }
28 10
 }

+ 0
- 23
src/main/java/io/zipcoder/casino/Card.java Näytä tiedosto

@@ -1,23 +0,0 @@
1
-package io.zipcoder.casino;
2
-
3
-public class Card {
4
-    private Suit suit;
5
-    private Rank rank;
6
-
7
-    public Card(Suit suit, Rank rank) {
8
-        this.suit = suit;
9
-        this.rank = rank;
10
-    }
11
-
12
-    public Suit getSuit() {
13
-        return suit;
14
-    }
15
-
16
-    public Rank getRank() {
17
-        return rank;
18
-    }
19
-
20
-    public Integer getValue(){
21
-        return rank.primaryValue;
22
-    }
23
-}

+ 0
- 5
src/main/java/io/zipcoder/casino/Casino.java Näytä tiedosto

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

+ 5
- 0
src/main/java/io/zipcoder/casino/Dealer.java Näytä tiedosto

@@ -1,6 +1,11 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 public class Dealer extends Player {
4
+
5
+    public Dealer(String name, double moneyStartedWith) {
6
+        super(name, moneyStartedWith);
7
+    }
8
+
4 9
     public void dealCards(Player player, Card card){
5 10
 
6 11
     }

+ 0
- 58
src/main/java/io/zipcoder/casino/Deck.java Näytä tiedosto

@@ -1,58 +0,0 @@
1
-package io.zipcoder.casino;
2
-
3
-import java.util.ArrayList;
4
-import java.util.Collections;
5
-import java.util.List;
6
-import java.util.Stack;
7
-
8
-public class Deck {
9
-
10
-    private static Suit Suit;
11
-    private static Rank Rank;
12
-    private Stack<Card> deck;
13
-
14
-
15
-
16
-
17
-    public Deck(){
18
-        this.deck = new Stack<Card>();
19
-        for (Suit suit : Suit.values()){
20
-            for (Rank rank : Rank.values()){
21
-                deck.push(new Card(suit, rank));
22
-            }
23
-        }
24
-    }
25
-
26
-
27
-
28
-    public Integer size(){
29
-
30
-        return deck.size();
31
-    }
32
-
33
-    public Card popCard(){
34
-
35
-        return deck.pop();
36
-    }
37
-
38
-    public Card pushCard(Card card){
39
-
40
-        return deck.push(card);
41
-    }
42
-
43
-    public boolean isEmpty(){
44
-        return deck.isEmpty();
45
-
46
-    }
47
-
48
-    public void shuffleDeck(Stack<Card> deck){
49
-
50
-        Collections.shuffle(deck);
51
-
52
-    }
53
-
54
-//    public void peek(Card card){
55
-//        return deck.peek();
56
-//
57
-//}
58
-}

+ 0
- 34
src/main/java/io/zipcoder/casino/Hand.java Näytä tiedosto

@@ -1,34 +0,0 @@
1
-package io.zipcoder.casino;
2
-
3
-import java.util.ArrayList;
4
-import java.util.List;
5
-
6
-public class Hand {
7
-    private  List<Card> cards;
8
-
9
-    public Hand () {
10
-
11
-
12
-        this.cards = new ArrayList<>();
13
-    }
14
-
15
-    public void add(Card card){
16
-
17
-        this.cards.add(card);
18
-    }
19
-
20
-    public Integer getHandValue(){
21
-
22
-        return null;
23
-    }
24
-
25
-    public List<Card> getCards() {
26
-
27
-        return cards;
28
-    }
29
-
30
-    public void setCards(List<Card> cards) {
31
-
32
-        this.cards = cards;
33
-    }
34
-}

+ 27
- 3
src/main/java/io/zipcoder/casino/Player.java Näytä tiedosto

@@ -1,16 +1,21 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
-import io.zipcoder.casino.Hand;
4
-
5 3
 public class Player {
6 4
 
7 5
     private String name;
8 6
 
9 7
     private Hand hand;
10 8
 
11
-    public Player() {
9
+    private Wallet wallet;
10
+    private double wager;
11
+
12
+    public Player(String name, double moneyStartedWith) {
12 13
 
13 14
         this.hand = new Hand();
15
+
16
+        this.name = name;
17
+
18
+        this.wallet = new Wallet(moneyStartedWith);
14 19
     }
15 20
 
16 21
     public void addCard(Card card) {
@@ -28,4 +33,23 @@ public class Player {
28 33
         this.hand = hand;
29 34
     }
30 35
 
36
+    public String getName() {
37
+
38
+        return name;
39
+    }
40
+
41
+    public void setWager(double money) {
42
+        this.wager = money;
43
+        wallet.takeMoney(money);
44
+    }
45
+
46
+    public double getWalletAmount() {
47
+        return wallet.getCurrentAmount();
48
+    }
49
+
50
+    public double getWager() {
51
+
52
+        return wager;
53
+    }
54
+
31 55
 }

+ 0
- 31
src/main/java/io/zipcoder/casino/Rank.java Näytä tiedosto

@@ -1,31 +0,0 @@
1
-package io.zipcoder.casino;
2
-
3
-public enum Rank {
4
-    Ace(1,11),
5
-    Two(2),
6
-    Three(3),
7
-    Four(4),
8
-    Five(5),
9
-    Six(6),
10
-    Seven(7),
11
-    Eight(8),
12
-    Nine(9),
13
-    Ten(10),
14
-    Jack(10),
15
-    Queen(10),
16
-    King(10);
17
-
18
-    final Integer primaryValue;
19
-    final Integer secondaryValue;
20
-
21
-    Rank(Integer primaryValue, Integer secondaryValue) {
22
-        this.primaryValue = primaryValue;
23
-        this.secondaryValue = secondaryValue;
24
-
25
-    }
26
-
27
-    Rank(Integer primaryValue) {
28
-        this.primaryValue = primaryValue;
29
-        this.secondaryValue = primaryValue;
30
-    }
31
-}

+ 0
- 14
src/main/java/io/zipcoder/casino/Suit.java Näytä tiedosto

@@ -1,14 +0,0 @@
1
-package io.zipcoder.casino;
2
-
3
-public enum  Suit {
4
-    SPADE("♤"),
5
-    HEART("♥"),
6
-    CLUB("♧"),
7
-    DIAMOND("♢");
8
-
9
-    private final String symbol;
10
-
11
-    Suit(String symbol) {
12
-        this.symbol = symbol;
13
-    }
14
-}

+ 0
- 23
src/main/java/io/zipcoder/casino/Wallet.java Näytä tiedosto

@@ -1,23 +0,0 @@
1
-package io.zipcoder.casino;
2
-
3
-public class Wallet {
4
-
5
-    private double money;
6
-    private Integer id;
7
-
8
-    public double getMoney(double money) {
9
-        return money;
10
-    }
11
-
12
-    public double addMoney(double money, double amountAwarded){
13
-        money += amountAwarded;
14
-
15
-        return money;
16
-    }
17
-
18
-    public double takeMoney(double money, double amountRemoved){
19
-        money -= amountRemoved;
20
-
21
-        return money;
22
-    }
23
-}

+ 0
- 63
src/test/java/blackjackPlayerTest.java Näytä tiedosto

@@ -1,63 +0,0 @@
1
-import org.junit.Assert;
2
-import org.junit.Test;
3
-
4
-public class blackjackPlayerTest {
5
-
6
-    @Test
7
-
8
-    public void setBetTest() {
9
-
10
-        //Given
11
-        BlackjackPlayer blackjackPlayer = new BlackjackPlayer();
12
-
13
-        //When
14
-        double expected = 100.00;
15
-
16
-        double actual = blackjackPlayer.setBet(100.00);
17
-
18
-        //Then
19
-        Assert.assertEquals(expected, actual, 0);
20
-
21
-    }
22
-
23
-    @Test
24
-
25
-    public void getBetTest() {
26
-
27
-        //Given
28
-        BlackjackPlayer blackjackPlayer = new BlackjackPlayer();
29
-
30
-        //When
31
-        double actual = 100.00;
32
-
33
-        double expected = blackjackPlayer.getBet(100.00);
34
-
35
-        //Then
36
-        Assert.assertEquals(expected, actual, 0);
37
-
38
-    }
39
-
40
-    @Test
41
-
42
-    public void setWagerTest() {
43
-
44
-        //Given
45
-        BlackjackPlayer blackjackPlayer = new BlackjackPlayer();
46
-
47
-        //When
48
-        double expected = blackjackPlayer.setWager(100.00);
49
-
50
-        double actual = blackjackPlayer.getWager(100.00);
51
-
52
-        //Then
53
-        Assert.assertEquals(expected, actual, 0);
54
-
55
-    }
56
-
57
-    @Test
58
-
59
-    public void getWagerTest() {
60
-
61
-
62
-    }
63
-}

+ 0
- 16
src/test/java/io/zipcoder/casino/BlackjackDealerTest.java Näytä tiedosto

@@ -1,16 +0,0 @@
1
-package io.zipcoder.casino;
2
-
3
-import org.junit.Test;
4
-
5
-public class BlackjackDealerTest {
6
-
7
-    @Test
8
-    public void testDealCard(){
9
-
10
-    }
11
-
12
-    @Test
13
-    public void testTakeBet(){
14
-
15
-    }
16
-}

+ 45
- 0
src/test/java/io/zipcoder/casino/BlackjackPlayerTest.java Näytä tiedosto

@@ -0,0 +1,45 @@
1
+package io.zipcoder.casino;
2
+
3
+import io.zipcoder.casino.BlackjackPlayer;
4
+import org.junit.Assert;
5
+import org.junit.Before;
6
+import org.junit.Test;
7
+
8
+public class BlackjackPlayerTest {
9
+
10
+    BlackjackPlayer blackjackPlayer;
11
+
12
+
13
+    @Before
14
+    public void setup(){
15
+
16
+        blackjackPlayer  = new BlackjackPlayer("Xzavia", 200.00);
17
+
18
+    }
19
+
20
+    @Test
21
+    public void setWagerTest() {
22
+
23
+        //When
24
+        double actual = 100.00;
25
+
26
+        blackjackPlayer.setWager(100.00);
27
+
28
+        double expected = blackjackPlayer.getWager();
29
+
30
+        //Then
31
+        Assert.assertEquals(expected, actual, 0);
32
+    }
33
+
34
+    @Test
35
+    public void getNameTest() {
36
+
37
+        String expected = "Tommy";
38
+
39
+        String actual = blackjackPlayer.getName();
40
+
41
+        Assert.assertEquals(expected, actual);
42
+    }
43
+
44
+
45
+}

+ 0
- 5
src/test/java/io/zipcoder/casino/CasinoTest.java Näytä tiedosto

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

+ 0
- 16
src/test/java/io/zipcoder/casino/HandTest.java Näytä tiedosto

@@ -1,16 +0,0 @@
1
-package io.zipcoder.casino;
2
-
3
-import org.junit.Test;
4
-
5
-public class HandTest {
6
-
7
-    @Test
8
-    public void testAdd(){
9
-
10
-    }
11
-
12
-    @Test
13
-    public void testGetValue(){
14
-
15
-    }
16
-}

src/test/java/playerTest.java → src/test/java/io/zipcoder/casino/PlayerTest.java Näytä tiedosto

@@ -1,17 +1,27 @@
1
+package io.zipcoder.casino;
2
+
1 3
 import io.zipcoder.casino.*;
2 4
 import org.junit.Assert;
5
+import org.junit.Before;
3 6
 import org.junit.Test;
4 7
 
5 8
 import java.util.List;
6 9
 
7
-public class playerTest {
10
+public class PlayerTest {
8 11
 
9
-    @Test
12
+    Player xzavia;
13
+
14
+    @Before
15
+    public void setup(){
16
+
17
+        xzavia = new Player("Xzavia", 10_000.00);
18
+    }
10 19
 
20
+    @Test
11 21
     public void addCardTest() {
12 22
 
13 23
         //Given
14
-        Player xzavia = new Player();
24
+
15 25
         Card expected = new Card(Suit.SPADE, Rank.Jack);
16 26
 
17 27
         //When
@@ -20,7 +30,6 @@ public class playerTest {
20 30
 
21 31
         //Then
22 32
         Assert.assertEquals(expected, actual);
23
-
24 33
     }
25 34
 
26 35
     @Test
@@ -46,6 +55,7 @@ public class playerTest {
46 55
 
47 56
         //Given
48 57
         Card expected = new Card(Suit.SPADE, Rank.Jack);
58
+
49 59
         Hand hand = new Hand();
50 60
 
51 61
         //When
@@ -54,4 +64,20 @@ public class playerTest {
54 64
         //Then
55 65
 
56 66
     }
67
+
68
+    @Test
69
+    public void getWalletAmountAfterWager(){
70
+
71
+        //When
72
+        xzavia.setWager(1000.00);
73
+
74
+        double expected = 9000.00;
75
+
76
+        double actual = xzavia.getWalletAmount();
77
+
78
+        //Then
79
+        Assert.assertEquals(expected,actual,0);
80
+
81
+
82
+    }
57 83
 }

+ 0
- 40
src/test/java/io/zipcoder/casino/TestCard.java Näytä tiedosto

@@ -1,40 +0,0 @@
1
-package io.zipcoder.casino;
2
-
3
-import org.junit.Assert;
4
-import org.junit.Test;
5
-
6
-public class TestCard {
7
-
8
-    @Test
9
-    public void getSuitTest(){
10
-        //Given
11
-        Card aceOfSpade = new Card(Suit.SPADE, Rank.Ace);
12
-        Suit expectedSuit = Suit.SPADE;
13
-        //When
14
-        Suit actualSuit = aceOfSpade.getSuit();
15
-        //Then
16
-        Assert.assertEquals(expectedSuit, actualSuit);
17
-    }
18
-
19
-    @Test
20
-    public void getRankTest(){
21
-        //Given
22
-        Card twoOfHearts = new Card(Suit.HEART, Rank.Two);
23
-        Rank expectedRank = Rank.Two;
24
-        //When
25
-        Rank actualRank = twoOfHearts.getRank();
26
-        //Then
27
-        Assert.assertEquals(expectedRank, actualRank);
28
-    }
29
-
30
-    @Test
31
-    public void getValueTest(){
32
-        //Given
33
-        Card jackOfClub = new Card(Suit.CLUB, Rank.Jack);
34
-        Integer expectedValue = 10;
35
-        //When
36
-        Integer actualValue = Rank.Jack.primaryValue;
37
-        //Then
38
-        Assert.assertEquals(expectedValue, actualValue);
39
-    }
40
-}

+ 0
- 39
src/test/java/io/zipcoder/casino/TestDeck.java Näytä tiedosto

@@ -1,39 +0,0 @@
1
-package io.zipcoder.casino;
2
-
3
-import org.junit.Test;
4
-
5
-import java.util.Stack;
6
-
7
-
8
-public class TestDeck {
9
-
10
-    @Test
11
-    public void testDeckSize(){
12
-        //Given
13
-        Stack<Card> deckSize = new Stack<Card>();
14
-        //When
15
-
16
-        //Then
17
-    }
18
-
19
-    @Test
20
-    public void testPopCard(){
21
-        //Given
22
-        //When
23
-        //Then
24
-    }
25
-
26
-    @Test
27
-    public void testPushCard(){
28
-        //Given
29
-        //When
30
-        //Then
31
-    }
32
-
33
-    @Test
34
-    public void testDeckIsEmpty(){
35
-        //Given
36
-        //When
37
-        //Then
38
-    }
39
-}

+ 0
- 41
src/test/java/io/zipcoder/casino/TestWallet.java Näytä tiedosto

@@ -1,41 +0,0 @@
1
-package io.zipcoder.casino;
2
-
3
-import org.junit.Assert;
4
-import org.junit.Test;
5
-
6
-public class TestWallet {
7
-
8
-    @Test
9
-    public void testAddMoney(){
10
-        //Given
11
-        Wallet joeWallet = new Wallet();
12
-        double expectedMoney = 120.00;
13
-        //When
14
-        double actualMoney = joeWallet.addMoney(108.00,12.00);
15
-        //Then
16
-        Assert.assertEquals(expectedMoney, actualMoney, 0);
17
-    }
18
-
19
-    @Test
20
-    public void testTakeMoney(){
21
-        //Given
22
-        Wallet joeWallet = new Wallet();
23
-        double expectedMoney = 12.00;
24
-        //When
25
-        double actualMoney = joeWallet.takeMoney(24.00,12.00);
26
-        //Then
27
-        Assert.assertEquals(expectedMoney, actualMoney, 0);
28
-    }
29
-
30
-    @Test
31
-    public void testGetMoney(){
32
-        //Given
33
-        Wallet joeWallet = new Wallet();
34
-        double expectedMoney = 12.00;
35
-        //When
36
-        double actualMoney = joeWallet.getMoney(12.00);
37
-        //Then
38
-        Assert.assertEquals(expectedMoney, actualMoney, 0);
39
-    }
40
-
41
-}

+ 0
- 8
src/test/java/io/zipcoder/casino/playerTest.java Näytä tiedosto

@@ -1,8 +0,0 @@
1
-package io.zipcoder.casino;
2
-
3
-import org.junit.Test;
4
-
5
-@Test
6
-
7
-public class playerTest {
8
-}