Lauren Green пре 6 година
родитељ
комит
2895dccc44
2 измењених фајлова са 35 додато и 40 уклоњено
  1. 2
    25
      src/main/java/io/zipcoder/casino/Card.java
  2. 33
    15
      src/test/java/io/zipcoder/casino/CardTest.java

+ 2
- 25
src/main/java/io/zipcoder/casino/Card.java Прегледај датотеку

@@ -14,22 +14,15 @@ public class Card {
14 14
         this.name = cardValue + " of " + suit;
15 15
     }
16 16
 
17
+
17 18
     public String getName() {
18 19
         return name;
19 20
     }
20 21
 
21
-    public void setName(String name) {
22
-        this.name = name;
23
-    }
24
-
25 22
     public boolean isVisible() {
26 23
         return isVisible;
27 24
     }
28 25
 
29
-    public void setVisible(boolean visible) {
30
-        isVisible = visible;
31
-    }
32
-
33 26
     public void setVisibility(boolean visibility){
34 27
         isVisible = visibility;
35 28
     }
@@ -39,21 +32,11 @@ public class Card {
39 32
         return suit;
40 33
     }
41 34
 
42
-    public void setSuit(Suit suit)
43
-    {
44
-        this.suit = suit;
45
-    }
46
-
47 35
     public int getCardValue()
48 36
     {
49 37
         return cardValue.getCardValue();
50 38
     }
51 39
 
52
-    public void setCardValue(CardValue cardValue)
53
-    {
54
-        this.cardValue = cardValue;
55
-    }
56
-
57 40
     public enum CardValue
58 41
     {
59 42
         TWO(2),
@@ -94,11 +77,5 @@ public class Card {
94 77
         Suit (String suitValue)
95 78
         {
96 79
             this.suitValue = suitValue;
97
-        }
98
-
99
-        public String getSuitValue(){
100
-            return suitValue;
101
-        }
102
-
103
-    }
80
+        }}
104 81
 }

+ 33
- 15
src/test/java/io/zipcoder/casino/CardTest.java Прегледај датотеку

@@ -1,22 +1,40 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
+import org.junit.Assert;
3 4
 import org.junit.Test;
4 5
 
5
-import javax.smartcardio.Card;
6
-
7 6
 public class CardTest {
8 7
 
9
-//    @Test
10
-//    public void createCard(){
11
-//        Card card = new Card(Card.CardValue.TWO, Card.Suit.CLUBS);
12
-//        System.out.println(card.getName());
13
-//    }
14
-//
15
-//    @Test
16
-//    public void createCard2(){
17
-//        Card card = new Card(Card.CardValue.TWO, Card.Suit.CLUBS);
18
-//        Card card1 = new Card(Card.CardValue.QUEEN, Card.Suit.HEARTS);
19
-//        System.out.println(card.getName());
20
-//        System.out.println(card1.getName());
21
-//    }
8
+    @Test
9
+    public void testCreateCard(){
10
+        Card card = new Card(Card.CardValue.TWO, Card.Suit.CLUBS);
11
+        String expected = "TWO of CLUBS";
12
+        String actual = card.getName();
13
+        Assert.assertEquals(expected, actual);
14
+    }
15
+
16
+    @Test
17
+    public void testGetSuit(){
18
+        Card card = new Card(Card.CardValue.THREE, Card.Suit.DIAMONDS);
19
+        Card.Suit expected = Card.Suit.DIAMONDS;
20
+        Card.Suit actual = card.getSuit();
21
+        Assert.assertEquals(expected, actual);
22
+    }
23
+
24
+    @Test
25
+    public void testGetCardValue(){
26
+        Card card = new Card(Card.CardValue.ACE, Card.Suit.HEARTS);
27
+        int expected = 14;
28
+        int actual = card.getCardValue();
29
+        Assert.assertEquals(expected, actual);
30
+    }
31
+
32
+    @Test
33
+    public void testVisibility(){
34
+        Card card = new Card(Card.CardValue.KING, Card.Suit.SPADES);
35
+        boolean before = card.isVisible();
36
+        card.setVisibility(true);
37
+        boolean after = card.isVisible();
38
+        Assert.assertNotEquals(before, after);
39
+    }
22 40
 }