Przeglądaj źródła

Merge branch 'master' of laurengreen/ZCW-OOP-Casino into working

jonathan-hinds 6 lat temu
rodzic
commit
a3eeabd95a

+ 2
- 25
src/main/java/io/zipcoder/casino/Card.java Wyświetl plik

@@ -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
 }

+ 0
- 5
src/main/java/io/zipcoder/casino/CardGame.java Wyświetl plik

@@ -27,11 +27,6 @@ public abstract class CardGame {
27 27
     // public abstract void deal();
28 28
     // public abstract void deal(ArrayList<CardPlayer> players); // NEEDED FOR STUD
29 29
 
30
-    public void shuffle(){
31
-
32
-        //shuffle the card stack
33
-
34
-    }
35 30
 
36 31
     public Deck getDeck() {
37 32
         return deck;

+ 3
- 0
src/main/java/io/zipcoder/casino/War.java Wyświetl plik

@@ -114,6 +114,7 @@ public class War extends CardGame implements Gamble, Game {
114 114
         }
115 115
     }
116 116
 
117
+
117 118
     public void startGame(){
118 119
         Printer.printMessage("Welcome to War!");
119 120
         super.chooseStatingPlayer();
@@ -122,6 +123,8 @@ public class War extends CardGame implements Gamble, Game {
122 123
         startRound();
123 124
     }
124 125
 
126
+
127
+
125 128
     public void startRound() {
126 129
         while(super.getLoser() == null) {
127 130
             String input = console.getCMDFromUser("Type 'FLIP' to play the card at the top of your pile");

+ 2
- 2
src/main/java/io/zipcoder/casino/Yahtzee.java Wyświetl plik

@@ -1,7 +1,6 @@
1 1
 package io.zipcoder.casino;
2 2
 
3 3
 import java.util.ArrayList;
4
-import java.util.Scanner;
5 4
 
6 5
 public class Yahtzee extends DiceGame implements Game, Gamble {
7 6
 
@@ -46,7 +45,8 @@ public class Yahtzee extends DiceGame implements Game, Gamble {
46 45
                 int rollChoice = console.getIntFromUser("Would you like to:\n1. Roll all dice again.\n2. Roll some dice again.\n3. Stop rolling and score.\nNumber of Selection: ");
47 46
                 String diceToRoll = "";
48 47
                 if(rollChoice == 2) {
49
-                    diceToRoll = console.getLineFromUser("Which numbers would you like to reroll? List the numbers separated by spaces.");
48
+                    Console console2 = new Console();
49
+                    diceToRoll = console2.getLineFromUser("Which numbers would you like to reroll? List the numbers separated by spaces.");
50 50
                 }
51 51
                 rollOptions(rollChoice, diceToRoll); }
52 52
 

+ 27
- 7
src/test/java/io/zipcoder/casino/CardTest.java Wyświetl plik

@@ -1,20 +1,40 @@
1 1
 package io.zipcoder.casino;
2 2
 
3
+import org.junit.Assert;
3 4
 import org.junit.Test;
4 5
 
5 6
 public class CardTest {
6 7
 
7 8
     @Test
8
-    public void createCard(){
9
+    public void testCreateCard(){
9 10
         Card card = new Card(Card.CardValue.TWO, Card.Suit.CLUBS);
10
-        System.out.println(card.getName());
11
+        String expected = "TWO of CLUBS";
12
+        String actual = card.getName();
13
+        Assert.assertEquals(expected, actual);
11 14
     }
12 15
 
13 16
     @Test
14
-    public void createCard2(){
15
-        Card card = new Card(Card.CardValue.TWO, Card.Suit.CLUBS);
16
-        Card card1 = new Card(Card.CardValue.QUEEN, Card.Suit.HEARTS);
17
-        System.out.println(card.getName());
18
-        System.out.println(card1.getName());
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);
19 39
     }
20 40
 }

+ 1
- 0
src/test/java/io/zipcoder/casino/StudTest.java Wyświetl plik

@@ -244,6 +244,7 @@ public class StudTest {
244 244
     @Test //Either payAnte or Test is broken, Ante is not deducted. Test set to pass
245 245
     public void payAnteTest(){
246 246
         stud.payAnte(players);
247
+        System.out.println(players.get(0).getPlayer().getCurrentBalance());
247 248
         //WHEN @Before
248 249
         int expected = 10;
249 250
         //THEN