Selaa lähdekoodia

fixed merge conflict

Xcuello 6 vuotta sitten
vanhempi
commit
082f505f5c

+ 28
- 0
src/main/java/io/zipcoder/casino/BlackjackPlayer.java Näytä tiedosto

@@ -0,0 +1,28 @@
1
+package io.zipcoder.casino;
2
+
3
+public class BlackjackPlayer {
4
+
5
+    private double wager;
6
+
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;
26
+
27
+    }
28
+}

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

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

+ 33
- 10
src/main/java/io/zipcoder/casino/Deck.java Näytä tiedosto

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

+ 2
- 1
src/main/java/io/zipcoder/casino/Hand.java Näytä tiedosto

@@ -8,6 +8,7 @@ public class Hand {
8 8
 
9 9
     public Hand () {
10 10
 
11
+
11 12
         this.cards = new ArrayList<>();
12 13
     }
13 14
 
@@ -16,7 +17,7 @@ public class Hand {
16 17
         this.cards.add(card);
17 18
     }
18 19
 
19
-    public Integer getValue(){
20
+    public Integer getHandValue(){
20 21
 
21 22
         return null;
22 23
     }

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

@@ -1,10 +1,10 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 public enum  Suit {
4
-    Spade("♤"),
5
-    Heart("♥"),
6
-    Club("♧"),
7
-    Diamond("♢");
4
+    SPADE("♤"),
5
+    HEART("♥"),
6
+    CLUB("♧"),
7
+    DIAMOND("♢");
8 8
 
9 9
     private final String symbol;
10 10
 

+ 8
- 7
src/main/java/io/zipcoder/casino/Wallet.java Näytä tiedosto

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

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

@@ -8,8 +8,8 @@ public class TestCard {
8 8
     @Test
9 9
     public void getSuitTest(){
10 10
         //Given
11
-        Card aceOfSpade = new Card(Suit.Spade, Rank.Ace);
12
-        Suit expectedSuit = Suit.Spade;
11
+        Card aceOfSpade = new Card(Suit.SPADE, Rank.Ace);
12
+        Suit expectedSuit = Suit.SPADE;
13 13
         //When
14 14
         Suit actualSuit = aceOfSpade.getSuit();
15 15
         //Then
@@ -19,7 +19,7 @@ public class TestCard {
19 19
     @Test
20 20
     public void getRankTest(){
21 21
         //Given
22
-        Card twoOfHearts = new Card(Suit.Heart, Rank.Two);
22
+        Card twoOfHearts = new Card(Suit.HEART, Rank.Two);
23 23
         Rank expectedRank = Rank.Two;
24 24
         //When
25 25
         Rank actualRank = twoOfHearts.getRank();
@@ -30,7 +30,7 @@ public class TestCard {
30 30
     @Test
31 31
     public void getValueTest(){
32 32
         //Given
33
-        Card jackOfClub = new Card(Suit.Club, Rank.Jack);
33
+        Card jackOfClub = new Card(Suit.CLUB, Rank.Jack);
34 34
         Integer expectedValue = 10;
35 35
         //When
36 36
         Integer actualValue = Rank.Jack.primaryValue;

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

@@ -0,0 +1,39 @@
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
+}

+ 32
- 1
src/test/java/io/zipcoder/casino/TestWallet.java Näytä tiedosto

@@ -1,10 +1,41 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
+import org.junit.Assert;
4
+import org.junit.Test;
5
+
3 6
 public class TestWallet {
4
-    public void testAddMethod(){
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(){
5 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
+    }
6 29
 
30
+    @Test
31
+    public void testGetMoney(){
32
+        //Given
33
+        Wallet joeWallet = new Wallet();
34
+        double expectedMoney = 12.00;
7 35
         //When
36
+        double actualMoney = joeWallet.getMoney(12.00);
8 37
         //Then
38
+        Assert.assertEquals(expectedMoney, actualMoney, 0);
9 39
     }
40
+
10 41
 }

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

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

+ 3
- 3
src/test/java/playerTest.java Näytä tiedosto

@@ -12,7 +12,7 @@ public class playerTest {
12 12
 
13 13
         //Given
14 14
         Player xzavia = new Player();
15
-        Card expected = new Card(Suit.Spade, Rank.Jack);
15
+        Card expected = new Card(Suit.SPADE, Rank.Jack);
16 16
 
17 17
         //When
18 18
         xzavia.addCard(expected);
@@ -28,7 +28,7 @@ public class playerTest {
28 28
     public void getHandTest() {
29 29
 
30 30
         //Given
31
-        Card expected = new Card(Suit.Spade, Rank.Jack);
31
+        Card expected = new Card(Suit.SPADE, Rank.Jack);
32 32
         Hand hand = new Hand();
33 33
 
34 34
         //When
@@ -45,7 +45,7 @@ public class playerTest {
45 45
     public void setHandTest() {
46 46
 
47 47
         //Given
48
-        Card expected = new Card(Suit.Spade, Rank.Jack);
48
+        Card expected = new Card(Suit.SPADE, Rank.Jack);
49 49
         Hand hand = new Hand();
50 50
 
51 51
         //When