Quellcode durchsuchen

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

jonathan-hinds vor 6 Jahren
Ursprung
Commit
a3eeabd95a

+ 2
- 25
src/main/java/io/zipcoder/casino/Card.java Datei anzeigen

14
         this.name = cardValue + " of " + suit;
14
         this.name = cardValue + " of " + suit;
15
     }
15
     }
16
 
16
 
17
+
17
     public String getName() {
18
     public String getName() {
18
         return name;
19
         return name;
19
     }
20
     }
20
 
21
 
21
-    public void setName(String name) {
22
-        this.name = name;
23
-    }
24
-
25
     public boolean isVisible() {
22
     public boolean isVisible() {
26
         return isVisible;
23
         return isVisible;
27
     }
24
     }
28
 
25
 
29
-    public void setVisible(boolean visible) {
30
-        isVisible = visible;
31
-    }
32
-
33
     public void setVisibility(boolean visibility){
26
     public void setVisibility(boolean visibility){
34
         isVisible = visibility;
27
         isVisible = visibility;
35
     }
28
     }
39
         return suit;
32
         return suit;
40
     }
33
     }
41
 
34
 
42
-    public void setSuit(Suit suit)
43
-    {
44
-        this.suit = suit;
45
-    }
46
-
47
     public int getCardValue()
35
     public int getCardValue()
48
     {
36
     {
49
         return cardValue.getCardValue();
37
         return cardValue.getCardValue();
50
     }
38
     }
51
 
39
 
52
-    public void setCardValue(CardValue cardValue)
53
-    {
54
-        this.cardValue = cardValue;
55
-    }
56
-
57
     public enum CardValue
40
     public enum CardValue
58
     {
41
     {
59
         TWO(2),
42
         TWO(2),
94
         Suit (String suitValue)
77
         Suit (String suitValue)
95
         {
78
         {
96
             this.suitValue = suitValue;
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 Datei anzeigen

27
     // public abstract void deal();
27
     // public abstract void deal();
28
     // public abstract void deal(ArrayList<CardPlayer> players); // NEEDED FOR STUD
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
     public Deck getDeck() {
31
     public Deck getDeck() {
37
         return deck;
32
         return deck;

+ 3
- 0
src/main/java/io/zipcoder/casino/War.java Datei anzeigen

114
         }
114
         }
115
     }
115
     }
116
 
116
 
117
+
117
     public void startGame(){
118
     public void startGame(){
118
         Printer.printMessage("Welcome to War!");
119
         Printer.printMessage("Welcome to War!");
119
         super.chooseStatingPlayer();
120
         super.chooseStatingPlayer();
122
         startRound();
123
         startRound();
123
     }
124
     }
124
 
125
 
126
+
127
+
125
     public void startRound() {
128
     public void startRound() {
126
         while(super.getLoser() == null) {
129
         while(super.getLoser() == null) {
127
             String input = console.getCMDFromUser("Type 'FLIP' to play the card at the top of your pile");
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 Datei anzeigen

1
 package io.zipcoder.casino;
1
 package io.zipcoder.casino;
2
 
2
 
3
 import java.util.ArrayList;
3
 import java.util.ArrayList;
4
-import java.util.Scanner;
5
 
4
 
6
 public class Yahtzee extends DiceGame implements Game, Gamble {
5
 public class Yahtzee extends DiceGame implements Game, Gamble {
7
 
6
 
46
                 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: ");
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
                 String diceToRoll = "";
46
                 String diceToRoll = "";
48
                 if(rollChoice == 2) {
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
                 rollOptions(rollChoice, diceToRoll); }
51
                 rollOptions(rollChoice, diceToRoll); }
52
 
52
 

+ 27
- 7
src/test/java/io/zipcoder/casino/CardTest.java Datei anzeigen

1
 package io.zipcoder.casino;
1
 package io.zipcoder.casino;
2
 
2
 
3
+import org.junit.Assert;
3
 import org.junit.Test;
4
 import org.junit.Test;
4
 
5
 
5
 public class CardTest {
6
 public class CardTest {
6
 
7
 
7
     @Test
8
     @Test
8
-    public void createCard(){
9
+    public void testCreateCard(){
9
         Card card = new Card(Card.CardValue.TWO, Card.Suit.CLUBS);
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
     @Test
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 Datei anzeigen

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