Akeem Cherry 6 yıl önce
ebeveyn
işleme
e931077ceb

+ 23
- 0
src/main/java/io/zipcoder/casino/Card.java Dosyayı Görüntüle

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

+ 5
- 0
src/main/java/io/zipcoder/casino/Casino.java Dosyayı Görüntüle

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

+ 58
- 0
src/main/java/io/zipcoder/casino/Deck.java Dosyayı Görüntüle

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

+ 31
- 0
src/main/java/io/zipcoder/casino/Rank.java Dosyayı Görüntüle

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

+ 14
- 0
src/main/java/io/zipcoder/casino/Suit.java Dosyayı Görüntüle

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

+ 23
- 0
src/main/java/io/zipcoder/casino/Wallet.java Dosyayı Görüntüle

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

+ 5
- 0
src/test/java/io/zipcoder/casino/CasinoTest.java Dosyayı Görüntüle

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

+ 40
- 0
src/test/java/io/zipcoder/casino/TestCard.java Dosyayı Görüntüle

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

+ 40
- 0
src/test/java/io/zipcoder/casino/TestDeck.java Dosyayı Görüntüle

@@ -0,0 +1,40 @@
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
+        Integer expectedSize = deckSize
15
+        //When
16
+
17
+        //Then
18
+    }
19
+
20
+    @Test
21
+    public void testPopCard(){
22
+        //Given
23
+        //When
24
+        //Then
25
+    }
26
+
27
+    @Test
28
+    public void testPushCard(){
29
+        //Given
30
+        //When
31
+        //Then
32
+    }
33
+
34
+    @Test
35
+    public void testDeckIsEmpty(){
36
+        //Given
37
+        //When
38
+        //Then
39
+    }
40
+}

+ 41
- 0
src/test/java/io/zipcoder/casino/TestWallet.java Dosyayı Görüntüle

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