Demetrius Murray 6 년 전
부모
커밋
51050063cc

+ 2
- 3
src/main/java/io/zipcoder/casino/CardGame/Solitaire/Solitaire.java 파일 보기

10
 import static io.zipcoder.casino.CardGame.Solitaire.Tableau.tempStack;
10
 import static io.zipcoder.casino.CardGame.Solitaire.Tableau.tempStack;
11
 
11
 
12
 public class Solitaire extends CardGame {
12
 public class Solitaire extends CardGame {
13
-    //populate arrayTabs upon construction.
14
     //clean up.
13
     //clean up.
15
 
14
 
16
     //create setting for 3 card draw. which will affect the draw method.
15
     //create setting for 3 card draw. which will affect the draw method.
40
         for (int i = 0; i < arrayTabs.length; i++) {
39
         for (int i = 0; i < arrayTabs.length; i++) {
41
             for (int j = 0; j < arrayTabs.length; j++) {
40
             for (int j = 0; j < arrayTabs.length; j++) {
42
                 if (j >= i) arrayTabs[j].add(draw());
41
                 if (j >= i) arrayTabs[j].add(draw());
43
-                if (j == i) arrayTabs[i].stack.peek().setCovered(false);
44
-                else arrayTabs[i].stack.peek().setCovered(true);
42
+                if (j != i) arrayTabs[j].stack.peek().setCovered(true);
45
             }
43
             }
46
         }
44
         }
45
+        for(Tableau tab : arrayTabs) tab.stack.peek().setCovered(false);
47
     }
46
     }
48
 
47
 
49
     public void drawCard(){
48
     public void drawCard(){

+ 32
- 17
src/test/java/io/zipcoder/casino/CardGame/Solitaire/SolitaireTest.java 파일 보기

11
     Solitaire s = new Solitaire(new Player("Murphy"));
11
     Solitaire s = new Solitaire(new Player("Murphy"));
12
 
12
 
13
     @Test
13
     @Test
14
-    public void testfind(){
14
+    public void testfind() {
15
         s.resetDeck();
15
         s.resetDeck();
16
         s.tab1.add(toCard("Ace", "Hearts"));
16
         s.tab1.add(toCard("Ace", "Hearts"));
17
-        s.tab2.add(toCard("five","diamonds"));
17
+        s.tab2.add(toCard("five", "diamonds"));
18
 
18
 
19
-        System.out.println(s.findTab(toCard("Ace","Hearts")).stack.peek());
19
+        System.out.println(s.findTab(toCard("Ace", "Hearts")).stack.peek());
20
     }
20
     }
21
+
21
     @Test
22
     @Test
22
-    public void testPull(){
23
+    public void testPull() {
23
         s.resetDeck();
24
         s.resetDeck();
24
         s.tab1.add(toCard("Ace", "Hearts"));
25
         s.tab1.add(toCard("Ace", "Hearts"));
25
-        s.tab2.add(toCard("five","diamonds"));
26
+        s.tab2.add(toCard("five", "diamonds"));
26
 
27
 
27
         Integer preSize = s.tab1.size();
28
         Integer preSize = s.tab1.size();
28
-        s.pull(toCard("Ace","Hearts")); //main method tested
29
+        s.pull(toCard("Ace", "Hearts")); //main method tested
29
         Integer postSize = s.tab1.size();
30
         Integer postSize = s.tab1.size();
30
 
31
 
31
         Integer actual = preSize - postSize;
32
         Integer actual = preSize - postSize;
32
         Integer expected = 1;
33
         Integer expected = 1;
33
 
34
 
34
-        Assert.assertEquals(expected,actual);
35
+        Assert.assertEquals(expected, actual);
35
     }
36
     }
36
 
37
 
37
     @Test
38
     @Test
38
     public void drawCard() {
39
     public void drawCard() {
39
         s.drawCard();
40
         s.drawCard();
40
         System.out.println(s.wastePile.peek().toString());
41
         System.out.println(s.wastePile.peek().toString());
41
-        Assert.assertEquals(1,s.wastePile.size());
42
+        Assert.assertEquals(1, s.wastePile.size());
42
     }
43
     }
43
 
44
 
44
     @Test
45
     @Test
53
     }
54
     }
54
 
55
 
55
     @Test
56
     @Test
56
-    public void testDeal(){
57
+    public void testDeal() {
57
         s.resetDeck();
58
         s.resetDeck();
58
         s.deal();
59
         s.deal();
59
-        int i=0;
60
-        for (Tableau tab : s.arrayTabs){
61
-            System.out.println("tab " + i); i++;
60
+        int i = 0;
61
+        for (Tableau tab : s.arrayTabs) {
62
+            System.out.println("tab " + i);
63
+            i++;
62
             tab.stack.forEach(e -> System.out.println(e));
64
             tab.stack.forEach(e -> System.out.println(e));
63
-
65
+        }
64
         Assert.assertTrue(s.arrayTabs[0].size() == 1);
66
         Assert.assertTrue(s.arrayTabs[0].size() == 1);
65
         Assert.assertTrue(s.arrayTabs[1].size() == 2);
67
         Assert.assertTrue(s.arrayTabs[1].size() == 2);
66
         Assert.assertTrue(s.arrayTabs[2].size() == 3);
68
         Assert.assertTrue(s.arrayTabs[2].size() == 3);
68
         Assert.assertTrue(s.arrayTabs[4].size() == 5);
70
         Assert.assertTrue(s.arrayTabs[4].size() == 5);
69
         Assert.assertTrue(s.arrayTabs[5].size() == 6);
71
         Assert.assertTrue(s.arrayTabs[5].size() == 6);
70
         Assert.assertTrue(s.arrayTabs[6].size() == 7);
72
         Assert.assertTrue(s.arrayTabs[6].size() == 7);
71
-        Assert.assertTrue(s.solitaireDeck.deckOfCards.size() == (52-28));
72
-        }
73
+        Assert.assertTrue(s.solitaireDeck.deckOfCards.size() == (52 - 28));
73
     }
74
     }
74
 
75
 
75
     @Test
76
     @Test
76
-    public void testCoverage(){
77
-
77
+    public void testCoverage() {
78
+        s.resetDeck();
79
+        s.deal();
80
+        int i = 0;
81
+        for (Tableau tab : s.arrayTabs) {
82
+            System.out.println("tab " + i);
83
+            i++;
84
+            tab.stack.forEach(e -> System.out.println(e + " " + e.isCovered()));
85
+        }
86
+        Assert.assertFalse(s.arrayTabs[0].stack.peek().isCovered());
87
+        Assert.assertFalse(s.arrayTabs[1].stack.peek().isCovered());
88
+        Assert.assertFalse(s.arrayTabs[2].stack.peek().isCovered());
89
+        Assert.assertFalse(s.arrayTabs[3].stack.peek().isCovered());
90
+        Assert.assertFalse(s.arrayTabs[4].stack.peek().isCovered());
91
+        Assert.assertFalse(s.arrayTabs[5].stack.peek().isCovered());
92
+        Assert.assertFalse(s.arrayTabs[6].stack.peek().isCovered());
78
     }
93
     }
79
 }
94
 }